https://github.com/lordbaldwin1/leetcode
All of my solved LeetCode problems.
https://github.com/lordbaldwin1/leetcode
cpp javascript python
Last synced: about 1 year ago
JSON representation
All of my solved LeetCode problems.
- Host: GitHub
- URL: https://github.com/lordbaldwin1/leetcode
- Owner: lordbaldwin1
- Created: 2024-10-08T21:24:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-19T04:17:42.000Z (about 1 year ago)
- Last Synced: 2025-06-19T05:28:08.913Z (about 1 year ago)
- Topics: cpp, javascript, python
- Language: JavaScript
- Homepage:
- Size: 134 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Study Notes for NeetCode 150 Problems
## Contains Duplicate
- hash map
- iterate nums, flag map[num] or just make count, check if map[num] is defined
- return true if map[num] !== undefined
## Valid Anagram
- sort both, easy method
- hash map (optimal): check length, make count hash map of both
- iterate over one hash map's keys and check if map[key] === map2[key]
- for (const key in map)!!!!
## Two Sum
- hash map
- iterate through array
- calc diff between target and current number
- check if it exists and is not the current index
- return diff's index and current index
## Group Anagrams
- **First Method** Sorting
- hash map
- iterate through array of strings
- sort, push original string to map at sorted index
- return Object.values(map)
- **Optimal Method** Char Count
- hash map
- iterate through array of strings
- make array new array len 26 fill 0
- iterate through chars, fill char count "c.charCodeAt(0)"
- so same thing, joined char count array is key
- push og string to map
- return Object.values(map)
## Top K Frequent Elements
- **Easy Method** Sorting w/ hash map
- Make hash map with count
- Turn map into array where each element is array with num and count
- Sort array by count
- return array of top k elements
## Longest Consecutive Sequence
- Set
- iterate set
- if no num - 1, thats a set
- continue while(num[n + streak))
- keep track of longest