File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @param {number[][] } matrix
3+ * @param {number } target
4+ * @return {boolean }
5+ */
6+ let searchMatrix = function ( matrix , target ) {
7+ let y = matrix . length
8+ if ( ! y ) return false
9+ let x = matrix [ 0 ] . length
10+
11+ let row = y - 1
12+ let column = 0
13+ while ( row >= 0 && column < x ) {
14+ let val = matrix [ row ] [ column ]
15+ if ( val > target ) {
16+ row --
17+ } else if ( val < target ) {
18+ column ++
19+ } else if ( val === target ) {
20+ return true
21+ }
22+ }
23+ return false
24+ } ;
Original file line number Diff line number Diff line change 1+ let removeElements = function ( head , val ) {
2+ let root = new ListNode ( )
3+ root . next = head
4+ let cur = root
5+ while ( cur ) {
6+ let next = cur . next
7+ if ( ! next ) {
8+ break
9+ }
10+ let nextVal = next . val
11+ if ( nextVal === val ) {
12+ cur . next = cur . next . next
13+ } else {
14+ cur = cur . next
15+ }
16+ }
17+ return root . next
18+ }
You can’t perform that action at this time.
0 commit comments