10000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5865fee + 9fbab57 commit fefa6e5Copy full SHA for fefa6e5
71-80/74. Search a 2D Matrix.js
@@ -0,0 +1,13 @@
1
+var searchMatrix = function(matrix, target) {
2
+ for(let i = 0 ; i < matrix.length ; i++){
3
+ if(target > matrix[i][matrix[0].length-1] ){
4
+ continue
5
+ }
6
+ for(let j = 0 ; j < matrix[0].length ; j++){
7
+ if(matrix[i][j] == target){
8
+ return true
9
10
11
12
+ return false
13
+};
71-80/75. Sort Colors.js
@@ -0,0 +1,17 @@
+var sortColors = function(nums) {
+ let obj = {}
+ let l = nums.length
+ if(l == 1){return nums}
+ for(let i = 0 ; i < l ;i++){
+ obj[nums[i]]= (obj[nums[i]])?obj[nums[i]]+1:1
+ let j = 0
+ for(let x in obj){
+ while(obj[x] > 0){
+ if(nums[j] < x){}
+ nums[j] = +x
+ obj[x]--
14
+ j++
15
16
17
0 commit comments