coding question

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 Charactersarrow-up-right

use a duplicateIndex = [];

15 3sum 3Sum Closesarrow-up-rightt 3Sum With Multiplicityarrow-up-right

for loop, left = i+ 1; right = length -1; while(left < right)....if else

20 Valid Parenthesesarrow-up-right

push ), ], } into array, use pop();

26 Remove Duplicates from Sorted Array

nums.splice(i, 1); i--;

27 Remove Elementarrow-up-right

nums.splice(i, 1), i--;

33 Search in Rotated Sorted Arrayarrow-up-right

toxic

36 Valid Sudoku

39 Combination Sumarrow-up-right

iterative, help(index + 1, array, target - candidates[index]);

46 Permutationsarrow-up-right

48 Rotate Imagearrow-up-right

49

73 Set Matrix Zeroesarrow-up-right

80 Remove Duplicates from Sorted Array IIarrow-up-right

splice(), O(n)

88 Merge Sorted Arrayarrow-up-right

94 Binary Tree Inorder Traversalarrow-up-right

102 Binary Tree Level Order Traversalarrow-up-right

121 array / dp Best Time to Buy and Sell Stockarrow-up-right

tempmin, tempmax, res. for loop ON/// try to use reduce

***** 125 Valid Palindrom

let str = s.replace(/\W/g, '').toLowerCase();

144 Binary Tree Preorder Traversalarrow-up-right

151 Reverse Words in a Stringarrow-up-right

155 Min Stackarrow-up-right

192 Word Frequencyarrow-up-right

203 Remove Linked List Elementsarrow-up-right

204 Count Primesarrow-up-right

206 Reverse Linked Listarrow-up-right

238 Product of Array Except Selfarrow-up-right

268 Missing Numberarrow-up-right

use sum, reduce get array sum, diff.

283 Move Zeroesarrow-up-right

from back to front.

300 Longest Increasing Subsequencearrow-up-right

316 Remove Duplicate Lettersarrow-up-right

349 Intersection of Two Arraysarrow-up-right

387 String First Unique Character in a String

2 pass;

394 Decode Stringarrow-up-right

509 Fibonacci closure

819 Most Common Wordarrow-up-right

Use array/Object for any question.

string = array.join("");

no need queue, stack, map

Last updated