Merge two arrays of objects
let first=[
{uuid: 2, name: 'Darling'},
{uuid: 3, name: 'Cry-Baby'},
{uuid: 4, name: 'Snitch'},
{uuid: 5, name: 'Pawn'}
];
let second= [
{uuid: 1, role: 'admin'},
{uuid: 2, role: 'contributor'},
{uuid: 3, role: 'owner'},
{uuid: 4, role: 'contributor'}
];
//[
// {uuid:1, name: null, role: 'admin'},
// {uuid:2, name: 'Darling', role: 'contributor'},
// {uuid:3, name: 'Cry-Baby', role: 'owner'},
// {uuid:4, name: 'Snitch', role: 'contributor'},
// {uuid:5, name: 'Pawn', role: null}
//]
Count array occurs highest
delete node in inkedlist
top two frequents in array
flattern object/array
closure:
Fibonacci closure:
use closure to change loop / use a closure to create a private counter?
closure in callback
Leetcode
1 2sum
3 string/array use map Longest Substring Without Repeating Characters
use a duplicateIndex = [];
15 3sum 3Sum Closest 3Sum With Multiplicity
for loop, left = i+ 1; right = length -1; while(left < right)....if else
20 Valid Parentheses
push ), ], } into array, use pop();
26 Remove Duplicates from Sorted Array
nums.splice(i, 1); i--;
27 Remove Element
nums.splice(i, 1), i--;
33 Search in Rotated Sorted Array
toxic
36 Valid Sudoku
39 Combination Sum
iterative, help(index + 1, array, target - candidates[index]);
46 Permutations
48 Rotate Image
49
73 Set Matrix Zeroes
80 Remove Duplicates from Sorted Array II
splice(), O(n)
88 Merge Sorted Array
94 Binary Tree Inorder Traversal
102 Binary Tree Level Order Traversal
121 array / dp Best Time to Buy and Sell Stock
tempmin, tempmax, res. for loop ON/// try to use reduce
***** 125 Valid Palindrom
let str = s.replace(/\W/g, '').toLowerCase();
144 Binary Tree Preorder Traversal
151 Reverse Words in a String
155 Min Stack
192 Word Frequency
203 Remove Linked List Elements
204 Count Primes
206 Reverse Linked List
238 Product of Array Except Self
268 Missing Number
use sum, reduce get array sum, diff.
283 Move Zeroes
from back to front.
300 Longest Increasing Subsequence
316 Remove Duplicate Letters
349 Intersection of Two Arrays
387 String First Unique Character in a String
2 pass;
394 Decode String
509 Fibonacci closure
819 Most Common Word
Use array/Object for any question.
string = array.join("");
no need queue, stack, map