Skip to content

Commit 4e6cc37

Browse files
Update and rename Questions to Questions.md
1 parent 8fde4d0 commit 4e6cc37

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
** Q1) SORTED ARRAYS MERGE **
2+
**Q1) SORTED ARRAYS MERGE**
33

44
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.
55

@@ -8,33 +8,45 @@ Merge nums1 and nums2 into a single array sorted in non-decreasing order.
88
The final sorted array should not be returned, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.
99

1010
Example 1:
11+
1112
Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6] Explanation: The arrays we are merging are [1,2,3] and [2,5,6]. The result of the merge is [1,2,2,3,5,6] with the underlined elements coming from nums1.
1213

1314
Example 2:
15+
1416
Input: nums1 = [1], m = 1, nums2 = [], n = 0 Output: [1] Explanation: The arrays we are merging are [1] and []. The result of the merge is [1].
1517

1618
Example 3:
19+
1720
Input: nums1 = [0], m = 0, nums2 = [1], n = 1 Output: [1] Explanation: The arrays we are merging are [] and [1]. The result of the merge is [1]. Note that because m = 0, there are no elements in nums1. The 0 is only there to ensure the merge result can fit in nums1.
1821

1922
Input Format:
23+
2024
The first line contains two integers m and n - the number of elements of array num1 and num2.
25+
2126
The second line contains the elements of the array num1.
27+
2228
The third line contains the elements of the array num2.
2329

2430
Constraints:
31+
2532
nums1.length == m + n
33+
2634
nums2.length == n
35+
2736
0 <= m, n <= 200
37+
2838
1 <= m + n <= 200
39+
2940
-109 <= nums1[i], nums2[j] <= 109
3041

3142
Output Format:
43+
3244
Output in a single line the merged sorted array.
3345

3446

3547

3648

37-
** Q2) MINIMUM COINS **
49+
**Q2) MINIMUM COINS**
3850

3951
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
4052

@@ -43,58 +55,77 @@ Return the fewest number of coins that you need to make up that amount. If that
4355
You may assume that you have an infinite number of each kind of coin.
4456

4557
Input Format:
58+
4659
First line contains n, the length of the integer array.
60+
4761
Second line contains the elements of the integer array.
62+
4863
Third line contains the amount.
4964

5065
Constraints:
66+
5167
1) 1 <= coins.length <= 12
5268
2) 1 <= coins[i] <= 231 - 1
5369
3) 0 <= amount <= 104
5470

5571
Output Format:
72+
5673
Output the fewest number of coins required to get the amount.
5774

5875

5976

6077

61-
** Q3) ISLANDS **
78+
**Q3) ISLANDS**
6279

6380
Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.
6481

6582
An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
6683

6784
Input Format:
85+
6886
First line contains two integers m,n - rows and columnns of the matrix, respectively.
87+
6988
Next, m lines begins. Each line contains n elements in it.
7089

7190
Constraints:
91+
7292
m == grid.length
93+
7394
n == grid[i].length
95+
7496
1 <= m, n <= 300
97+
7598
grid[i][j] is '0' or '1'.
7699

77100
Output Format:
101+
78102
Output the number of islands.
79103

80104

81105

82106

83-
** Q4) TRAPPING RAIN WATER **
107+
**Q4) TRAPPING RAIN WATER**
84108

85109
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
86110

87111
Example 1:
112+
88113
Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped.
89114

90115
Input Format:
116+
91117
The first line contains one integer n - the size of array
118+
92119
The second line contains the elements of the array.
93120

94121
Constraints:
122+
95123
n == height.length
124+
96125
1 <= n <= 2 * 104
126+
97127
0 <= height[i] <= 105
98128

99129
Output Format:
130+
100131
Output in one line - the water it can trap after raining.

0 commit comments

Comments
 (0)