Given an array of integers nums.
A pair (i,j) is called good if nums[i] == nums[j] and i < j.
Return the number of good pairs.
Input: nums = [1,2,3,1,1,3]
Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
Input: nums =[……]
Given the array nums consisting of 2n elements in the form [x1,x2,…,xn,y1,y2,…,yn].
Return the array in the form [x1,y1,x2,y2,…,xn,yn].
Input: nums = [2,5,1,3,4,7], n = 3
Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is[……]
Given the array candies and the integer extraCandies, where candies[i] represents the number of candies that the ith kid has.
For each kid check if there is a way to distribute extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple[……]
Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods:
1. updateSubrectangle(int row1, int col1, int row2, int col2, int newValue)
Updates all values with newValue in the subrectangle whose upper left[……]
A string S of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.
Input: S = “ababcbacadefegdehijhklij”
1305. All Elements in Two Binary Search Trees
Add to List
Given two binary search trees root1 and root2.
Return a list containing all the integers from both trees sorted in ascending order.
Input: root1 = [2,1,4], root2 = [1,0,3]
Given a string s formed by digits (‘0’ – ‘9’) and ‘#’ . We want to map s to English lowercase characters as follows:
Characters (‘a’ to ‘i’) are represented by (‘1’ to ‘9’) respectively.
Characters (‘j’ to ‘z’) are represented by (’10#’ to ’26#’) respectively.
Return the string formed after ma[……]
You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.
It is guaranteed that the graph of paths forms a line without any loop, therefor[……]
Given an integer n, return any array containing n unique integers such that they add up to 0.
Input: n = 5
Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].
Input: n = 3
Input: n =[……]
Given n and m which are the dimensions of a matrix initialized by zeros and given an array indices where indices[i] = [ri, ci]. For each pair of [ri, ci] you have to increment all cells in row ri and column ci by 1.
Return the number of cells with odd values in the matrix after applying the incre[……]