LeetcodeGrind

Repository to store Leetcode practice files

Confused About Algorithm

  1. Climbing Stairs
  2. Longest Palindrome
  3. Validate Binary Search Tree
  4. Maximum Depth of Binary Tree
  5. Dota2 Senate
  6. Increasing Triplet Subsequence
  7. Path Sum III
  8. Reorder Routes to Make All Paths Lead to the City Zero

Questions Which I can Improve the Algorithm

  1. Bulls and Cows
  2. Counting Bits
  3. Product of Array Except Self
  4. Maximum Twin Sum of a Linked List
  5. Determine if Two Strings Are Close

Confused About Time/Space Compexity

  1. Decode String
  2. N-ary Tree Postorder Traversal
  3. Validate Binary Search Tree
  4. Maximum Depth of Binary Tree
  5. Keys and Rooms
  6. Letter Combinations of a Phone Number
  7. Daily Temperatures
  8. Nearest Exit from Entrance in Maze
  9. Combination Sum III

Confused Concepts

DFS Dynamic Programming Sliding Window

Important Functions

1. sort()

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]

2. Object.entries()

const obj = { 10: 'adam', 200: 'billy', 35: 'chris' }; console.log(Object.entries(obj)) // [["10", "adam"], ["35", "chris"],["200", "billy"]]

3. for(let element of array)

Iterates through each element of an array

4. for(let key of object)

Iterates through each key of object, value can be accessed using object[key]

5. localeCompare()

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

6. reverse()

Reverses an array