Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9fbab57

Browse filesBrowse files
committed
73rd problem
1 parent c79ba7c commit 9fbab57
Copy full SHA for 9fbab57

File tree

2 files changed

+30
-0
lines changed
Filter options

2 files changed

+30
-0
lines changed

‎71-80/74. Search a 2D Matrix.js

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var sortColors = function(nums) {
2+
let obj = {}
3+
let l = nums.length
4+
if(l == 1){return nums}
5+
for(let i = 0 ; i < l ;i++){
6+
obj[nums[i]]= (obj[nums[i]])?obj[nums[i]]+1:1
7+
}
8+
let j = 0
9+
for(let x in obj){
10+
while(obj[x] > 0){
11+
if(nums[j] < x){}
12+
nums[j] = +x
13+
obj[x]--
14+
j++
15+
}
16+
}
17+
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.