
Given an array of integers nums and an integer target, return indices of the two numbers such that they
add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element
twice. You can return the answer in any order.
Example :
Input 1 :
nums = [2,7,11,15], target = 9
Output 1 :
[0,1]
Explanation :
Because nums[0] + nums[1] == 9, we return [0, 1].
Input 2 :
nums = [3,2,4], target = 6
Output 2 :
[1,2]
Constraints :
• 2 <= nums.length <= 104
• 109 <= nums[i] <= 109
• 109 <= target <= 109
• Only one valid answer exists.

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b],
nums[c], nums[d]] such that:.
• 0
<= a, b, c, d < n
• a, b, c, and d are distinct.
• nums[a] + nums[b] + nums[c] + nums[d] == targe
You can return the answer in any order.
Example :
Input 1 :
nums = [1,0,1,0,2,2], target = 0
Output 1 :
[[2,1,1,2],[2,0,0,2],[1,0,0,1]]
Input 2 :
nums = [2,2,2,2,2], target = 8
Output 2 :
[[2,2,2,2]]
Constraints :
• 1 <= nums.length <= 200
• 109 <= nums[i] <= 109
• 109 <= target <= 109

Given an array of integers nums sorted in ascending order, find the starting and ending position of a
given target value.
If target is not found in the array, return [1, 1]. You must write an algorithm with O(log n) runtime
complexity.
Example :
Input 1 :
nums = [5,7,7,8,8,10], target = 8
Output 1 :
[3,4]
Input 2 :
nums = [5,7,7,8,8,10], target = 6
Output 2 :
[1,1]
Constraints :
• 0 <= nums.length <= 105
• 109 <= nums[i] <= 109
• nums is a nondecreasing array.
• 109 <= target <= 109

Given a triangle array, return the minimum path sum from top to bottom.
For each step, you may move to an adjacent number of the row below. More formally, if you are on index
i on the current row, you may move to either index i or index i + 1 on the next row.
Example :
Input 1 :
triangle = [[2],[3,4],[6,5,7],[4,1,8,3]]
Output 1 :
11
Explanation :
The triangle looks like:
2
3 4
6 5 7
4 1 8 3
The minimum path sum from top to bottom is 2 + 3 + 5 + 1 = 11
Input 2 :
triangle = [[10]]
Output 2 :
10
Constraints :
• 1 <= triangle.length <= 200
• triangle[0].length == 1
• triangle[i].length == triangle[i  1].length + 1
• 104 <= triangle[i][j] <= 10^{4}

Given an array of integers arr, sort the array by performing a series of pancake flips.
In one pancake flip we do the following steps:
• Choose an integer k where 1
<= k <=arr.length.
• Reverse the subarray arr[0...k1] (0indexed)
For example, if arr = [3,2,1,4] and we performed a pancake flip choosing k = 3, we reverse the
subarray [3,2,1], so arr = [1,2,3,4] after the pancake flip at k = 3. Return an array of the kvalues
corresponding to a sequence of pancake flips that sort arr. Any valid answer that sorts the array within
10 * arr.length flips will be judged as correct.
Example :
Input 1 :
arr = [3,2,4,1]
Output 1 :
[4,2,4,3]
Explanation :
We perform 4 pancake flips, with k values 4, 2, 4, and 3.
Starting state: arr = [3, 2, 4, 1]
After 1st flip (k = 4): arr = [1, 4, 2, 3]
After 2nd flip (k = 2): arr = [4, 1, 2, 3]
After 3rd flip (k = 4): arr = [3, 2, 1, 4]
After 4th flip (k = 3): arr = [1, 2, 3, 4], which is sorted.
Input 2 :
arr = [1,2,3]
Output 2 :
[]
Explanation :
The input is already sorted, so there is no need to flip anything.
Note that other answers, such as [3, 3], would also be accepted.
Constraints :
• 1 <= arr.length <= 100
• 1 <= arr[i] <= arr.length
• All integers in arr are unique