Skip to content

Commit 3e88952

Browse files
Merge pull request #3 from AnwarHossainSR/dev1.0
Dev1.0
2 parents c009ac7 + a02f505 commit 3e88952

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

21-mergeTwoSortedList.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const mergeTwoLists = (l1, l2) => {
2+
if (!l1) return l2;
3+
if (!l2) return l1;
4+
if (l1.val < l2.val) {
5+
l1.next = mergeTwoLists(l1.next, l2);
6+
return l1;
7+
}
8+
l2.next = mergeTwoLists(l1, l2.next);
9+
return l2;
10+
};
11+
12+
console.log(mergeTwoLists([1, 2, 4], [1, 3, 4]));

26-removeDuplicates.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
var removeDuplicates = function (nums) {
3+
let i = 0;
4+
while (i < nums.length) {
5+
if (nums[i] === nums[i + 1]) {
6+
nums.splice(i, 1);
7+
} else {
8+
i++;
9+
}
10+
}
11+
return nums.length;
12+
};
13+
console.log(removeDuplicates([0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4]));

0 commit comments

Comments
 (0)