232. Implement Queue using StacksNode:
Use two queue to implement stack
Time Complexity && Space Complexity
Time Com...
String(Immutable in JS)Common solutions
Combine two string, check the combined include the orignal one
Reverse the whole sent...
151. Reverse Words in a StringNode:
I used split and reverse at first, actually the time complexity of split and reverse is O...
344. Reverse StringNode:
Two pointers
Reverse inplaceThe reverse() method of Array instances reverses an array in place and r...
454. 4Sum IINode:
Create an arrA which is sum of the Combination of arr1 and arr2, and an arrB which is sum of the Combinatio...
242. Valid AnagramNode:
Could also use array, since there are only 26 letters
every letter index is char.charCodeAt() - “a”.c...
24. Swap Nodes in PairsNode:
Understand Space Complexity(O(1))
second variable is assigned the reference to a exist node in t...
203. Remove Linked List ElementsNode:- Create a dummy header
- Need another while inside the while, which is for the case lik...
209. Minimum Size Subarray SumNote:
sliding window: a fixed or variable-size window is moved through a data structure, to sol...
Concept
Time Complexity: The Time Complexity of an algorithm/code is not equal to the actual time required to execute a ...