// Two Pointers
for(i=0; i<nums.length/2; i++)
console.log(nums[i], nums[nums.length-i-1])
// Binary Search
(arr, v, start = 0, end = arr.length - 1) => {
while (end - start > 1) {
if (arr[start] == v) return start
if (arr[end] == v) return end
v < arr[start] ? start += ~~(end/2) : end -= ~~((start+end)/2)
}
return -1
}
// Reverse linked list
let prev = null;
while(head) {
let saveNext = head.next
head.next = prev
prev = head
head = saveNext
}
return prev
-
Notifications
You must be signed in to change notification settings - Fork 0
digplan/code-problems
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published