Repository to store Leetcode practice files
- Climbing Stairs
- Longest Palindrome
- Validate Binary Search Tree
- Maximum Depth of Binary Tree
- Dota2 Senate
- Increasing Triplet Subsequence
- Path Sum III
- Reorder Routes to Make All Paths Lead to the City Zero
- Bulls and Cows
- Counting Bits
- Product of Array Except Self
- Maximum Twin Sum of a Linked List
- Determine if Two Strings Are Close
- Decode String
- N-ary Tree Postorder Traversal
- Validate Binary Search Tree
- Maximum Depth of Binary Tree
- Keys and Rooms
- Letter Combinations of a Phone Number
- Daily Temperatures
- Nearest Exit from Entrance in Maze
- Combination Sum III
DFS Dynamic Programming Sliding Window
Swap if value returned is POSITIVE DO NOT Swap if value returned is NEGATIVE
let array = [3, 1, 2, 4, 5]; array.sort((a, b) => a - b); // [1, 2, 3, 4, 5] array.sort((a, b) => b - a); // [5, 4, 3, 2, 1]
const obj = { 10: 'adam', 200: 'billy', 35: 'chris' }; console.log(Object.entries(obj)) // [["10", "adam"], ["35", "chris"],["200", "billy"]]
Iterates through each element of an array
Iterates through each key of object, value can be accessed using object[key]
const str1 = 'apple'; const str2 = 'banana'; const str3 = 'Apple';
console.log(str1.localeCompare(str2)); // -1 console.log(str2.localeCompare(str1)); // 1 console.log(str1.localeCompare(str3)); // -1 console.log(str3.localeCompare(str1)); // 1
Reverses an array