LC Study Flashcards

1
Q
  1. Word Break
A

to get runtime complexity, count non-leaf nodes similar to decode ways, easier tho runtime recursion brute-force: 2^n. with memo: O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Maximum Product Subarray
A

holy fuck… i got

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Set Matrix Zeroes
A

look at submission

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Find K Closest Elements
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

237 Delete Node in a Linked List

A

have to set the next to null, if you want to remove a node. “node = null” does not work bc “node” is just a var and doesn’t alter the actual object, ~duh~. Could have used only two lines and no loop… silly boy..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. Path Sum
A

DEFINITION OF ROOT-LEAF. IF THERE EXISTS ANOTHER CHILD, IT IS NOT A LEAF

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. Permutation in String
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. Task Scheduler
A

2 diff ways with pri queue Do the calculation way

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. Combination Sum
A

-best way to find how to get to target

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. Binary Tree Level Order Traversal
A

bfs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. Sort List
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. Maximum Binary Tree
A

difficult

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. K Closest Points to Origin
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. The Skyline Problem
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. House Robber II
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. Sort Characters By Frequency
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
  1. Binary Search Tree Iterator
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
  1. Merge Intervals
A

interesting, reference the result array to make decisions and update, idk nothing to say

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
  1. Decode Ways
A

the zero case is absolute asshole not dealing with this,….. you need to have the index represent the length or you will kys aids

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
  1. Alien Dictionary
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
  1. Intersection of Two Arrays
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q
  1. Fizz Buzz
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
  1. Reverse Nodes in k-Group
A

Use ‘nxt’ for next node name!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q
  1. Clone Graph
A

submitted: both dfs and bfs solutions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q
  1. Verifying an Alien Dictionary
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q
  1. Concatenated Words
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q
  1. Critical Connections in a Network
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q
  1. Longest Substring Without Repeating Characters
A

sliding window try optimized version heuehuehue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q
  1. Valid Parentheses
A

wrong data structure, hubris thought i remembered soln, didn’t check given test cases against my soln ;/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q
  1. Linked List Cycle
A

Object equivalencies! use “==” and it will check if its the same object Make it nice, easier to just have more null checks than to do something fancy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q
  1. Find the Duplicate Number
A

constraints are for hard question

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q
  1. Subtree of Another Tree
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

101 Symmetric Tree

A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q
  1. Word Search
A

dfs, not looking at already used letters just have dfs go to all neighbors, and have a general check for if it is correct char or out of bounds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q
  1. Remove Duplicates from Sorted List
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q
  1. Implement Queue using Stacks
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q
  1. Longest Common Prefix
A

edge case of single element. Think of these things pls vertical scanning fastest, do it next time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q
  1. Palindrome Partitioning
A

2 parts: longest palindorme dp array and then backtracking with partitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q
  1. Serialize and Deserialize Binary Tree
A

Do iterative, learned iterator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q
  1. Substring with Concatenation of All Words
A

see sliding window notes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q
  1. Target Sum
A

dynamic programming good problem, indexing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q
  1. Move Zeros
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q
  1. IPO
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q
  1. Binary Tree Maximum Path Sum
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q
  1. Diagonal Traverse
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q
  1. Reorder Data in Log Files
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q
  1. Divide Two Integers
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q
  1. Sliding Window Maximum
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q
  1. Jump Game
A

simple soln

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

5 Longest Palindromic

A

rly good and hard, 2 methods, DP and expand from middle I did a shitty implementation of DP, try expand from middle Update: actually not so shitty after all, looks good for DP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q
  1. Interval List Intersections
A

The interval with the shortest end point for sure doesn’t have any further overlap in the array. The one with shortest start point might very well have more overlap…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q
  1. Reverse Words in a String II
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

121 Best time to buy and sell stock 1

A

I got it right but I needed to increment at the end. I used a roundabout whileloop way, but should use the more efficient forloop one-pass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q
  1. Queue Reconstruction by Height
A

insert() behavior important

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q
  1. Word Ladder
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

242 Valid Anagram

A

sorting is actually longer than mapping to array sorting nlogn

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q
  1. Kth Smallest Element in a Sorted Matrix
A

heap and binary search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q
  1. Flatten Nested List Iterator
A

didnt understand q, DO AGAIN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q
  1. Design In-Memory File System
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q
  1. Find K Pairs with Smallest Sums
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q
  1. Maximum Width of Binary Tree
A

recursive and iterative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q
  1. Range Sum of BST
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q
  1. Search Suggestions System
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q
  1. Minimum Height Trees
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

11 Container with Most Water

A

traverse width dimension

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q
  1. Excel Sheet Column Number
A

understand the problem better

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q
  1. Spiral Matrix
A

main learning: just check if len(res) is less than number of elements in matrix every time look at most recent submission

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q
  1. Kth Largest Element in an Array
A

adding, removing to priorityqueue/heap/bst is lg(n) T(n) = T(n/2) + (n-1) => O(n) T(n) = T(n/2) => O(logn) (binary search) Tags: quicksort partition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q
  1. Reorganize String
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

21 Merge Sorted Lists

A

didn’t assume it was ordered, use recursion. sexy solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q
  1. Sparse Matrix Multiplication
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q
  1. Binary Tree Zigzag Level Order Traversal
A

Got bfs real good, DO DFS, it’s pretty cool 4/17: EDIT: Beautiful most recent solution with deq. FINAL ITERATIVE, Next do recursive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

78 Subsets

A

2 neat ways of solving: Super simple and sleek python contruction second is backtracking, don’t duplicate lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q
  1. Reverse Words in a String
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

19 Remove Nth Node

A

Mine is good, look at article it shows using dummy for head which is useful soln to removing head edge case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q
  1. Counting Bits
A

crazy, dp soln w/ pattern detecting (overlap subproblem) and really neat dp with odd/even soln

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q
  1. Sliding Window Median
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q
  1. Implement Trie (Prefix Tree)
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q
  1. Coin Change
A

KNOW RUNTIME, bottom up and top down stuff.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q
  1. Minimum Remove to Make Valid Parentheses
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q
  1. Convert BST to Greater Tree
A

There is a way to transfer info back up a tree, much harder tho, try global variable solution first and then discuss that way.

Morris traversal is interesting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
82
Q
  1. Vertical Order Traversal of a Binary Tree
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
83
Q
  1. Copy List with Random Pointer
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
84
Q
  1. Add Two Numbers
A

Get the implementation completely down. added new category :)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

344. Reverse String

A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
86
Q

217 Contains Dup

A

I used sorting solution. I thought would be faster because nlogn + n = nlogn, and worst case for hashtable insert (hashset) is O(n), so I thought that would be O(n^2), but solution says it is only O(1).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q
  1. Meeting Rooms
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
88
Q
  1. Add Binary
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q
  1. Design Tic-Tac-Toe
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
90
Q
  1. Read N Characters Given Read4 II - Call multiple times
A
  1. Ez python way, 2. other java/c++ way with array buffer.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
91
Q
  1. Valid Palindrome II
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
92
Q
  1. Longest Substring with At Most K Distinct Characters
A

DO THE FOLLOWUP IN DISCUSSIONS. UNDERSTAND OPTIMIZED! update: the ordered dictionary is for the follow-up: what if input is as a stream? ans: you need to store the leftmost character’s position… just look at soln article!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
93
Q
  1. Longest Consecutive Sequence
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
94
Q
  1. Implement Rand10() Using Rand7()
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
95
Q

172 Trailing Zeros

A

math

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
96
Q
  1. Employee Free Time
A

Do K-Way Merge Idea when you get to that lesson :)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
97
Q
  1. Encode and Decode Strings
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
98
Q
  1. sqrt()
A

O(sqrt(x)) solution not wrong, just make sure to check for overflow (i <= x / i) binary search solution practice (many ways to do bisearch)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
99
Q
  1. Reverse Words in a String III
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
100
Q
  1. Valid Number
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
101
Q
  1. Course Schedule III
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
102
Q
  1. Maximum Frequency Stack
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
103
Q
  1. Maximum Length of a Concatenated String with Unique Characters
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
104
Q
  1. Unique Paths
A

memo, weird matrix layout, try to understand and do yourself dp iteration, look at most recent submission

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
105
Q
  1. Binary Search
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
106
Q
  1. Analyze User Website Visit Pattern
A

e

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
107
Q
  1. Populating Next Right Pointers in Each Node II
A

I used solution article, keep with sachin my boi, other discussion solutions are gay as fuck

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
108
Q
  1. Validate Binary Search Tree
A

try iteration(stack), and in-order next time too

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
109
Q
  1. Diameter of Binary Tree
A

e

110
Q
  1. Course Schedule
A

cycle detection method and topological sort ***huge revisit, lot to learn from this one. didn’t really do cycle detection one but seems fun

111
Q
  1. Peeking Iterator
A

e

112
Q
  1. Accounts Merge
A

e

113
Q
  1. Letter Combinations of a Phone Number
A

e

114
Q
  1. Number of Distinct Islands
A

e

115
Q
  1. Shuffle an Array
A

another design similar to right above!! woooooooo!!!!!!! love it !!!! tyes1!!!!!!!! awassome!!!

116
Q
  1. Day of the Week
A

e

117
Q
  1. Insert Interval
A

dont waste time implementing a wrong algo… duh

118
Q
  1. Palindromic Substrings
A

dp and expand solutions

119
Q
  1. Minimum Path Sum
A

MAKE SPACE EFFICIENT sick O(n) space soln

120
Q

38 Count and say

A

Integer.toString() takes a long time, changed it just to result.append(times) where “times” is an integer *able to append int to StringBuilder

121
Q
  1. Random Pick Index
A

e

122
Q
  1. Search Insert Position
A

also a handle for dups

123
Q
  1. Validate IP Address
A

e

124
Q
  1. Majority Element
A

quick ans

125
Q
  1. Encode and Decode TinyURL
A

e

126
Q

66 Plus One

A

cool

127
Q
  1. Count Primes
A

ancient greek algorithm sieve of arasmuth cool (in hints)

128
Q
  1. Single Number
A

e

129
Q
  1. Squares of a Sorted Array
A

e

130
Q
  1. Same Tree
A

LEARNED: DFS iteratively uses stack. BFS iteratively uses a queue submitted: most recent is BFS using queue solution, next is recursion update: the dfs w/ stack is preorder

131
Q
  1. Unique Binary Search Trees
A

do dp.

132
Q
  1. Path Sum III
A

insane solution, got brute recursion tho, caching solution is muy dificil

133
Q
  1. Is Graph Bipartite?
A

e

134
Q
  1. Most Common Word
A

e

135
Q
  1. Number of Islands
A

e

136
Q
  1. Reverse Bits
A

unsigned left shift doesn’t exist, does the same as <

137
Q
  1. Snakes and Ladders
A

e

138
Q
  1. Two Sum
A

find the edge :/ same num used twice, don’t get too confident bruh one-pass available

139
Q
  1. Invert Binary Tree
A

bfs, dfs, recursive, iterative

140
Q
  1. Binary Tree Inorder Traversal
A

try without altering initial data structure, I forgot to reset the node’s left to null so it infinitely looped

141
Q
  1. Merge sorted Array
A

hit it from the baackkkk most recent submission the soln I like

142
Q
  1. Decode String
A

like flatten nest list, kinda unique stack question, hopefully anotherone like it somewhere

143
Q
  1. Permutations II
A

good, one extra step was to iterate on the counts, not the nums to not look at double.

144
Q
  1. Populating Next Right Pointers in Each Node
A

DO AGAIN

145
Q
  1. Valid Palindrome
A

skip completely alphanumeric, also isLetterOrDigit() try without extra space next time!

146
Q
  1. Regular Expression Matching
A

e

147
Q
  1. Exclusive Time of Functions
A

e

148
Q
  1. Top K Frequent Words
A

e

149
Q
  1. Random Pick with Weight
A

e

150
Q
  1. Search a 2D Matrix
A

cool cool cool cool

151
Q
  1. Find Minimum in Rotated Sorted Array
A

good to learn bisearch inside and out, so many edge cases. l < r if you want to break and return outside of loop use r = mid in order to close in on one specific target from two arrays, otherwise you lose a potential number jesus binary search is hard, keep trying and cross-comparing different q’s

152
Q
  1. Remove Invalid Parentheses
A

e

153
Q
  1. Boundary of Binary Tree
A

e

154
Q
  1. Minimum Depth of Binary Tree
A

iterative BFS (could attach depth to node w/ a tuple. I like generalized global mindepth tho its more like level order), Try all others versions (DFS, recursive).

155
Q
  1. LFU Cache
A

e

156
Q
  1. Minimum Number of Arrows to Burst Balloons
A

not easy in the slightest, greedy

157
Q

198 House Robber

A

practice the iterative version as well. Maybe take a crack at the 2 variable one

158
Q
  1. Rotting Oranges
A

e

159
Q
  1. Search in Rotated Sorted Array
A

two ways, 1: look if low and mid are on the same side, then do checks based on that (its either increasing from low to mid, or increasing from mid to high) 2: look at pivot to determine if mid and target are on the same side, then do checks based on that.

160
Q
  1. Flatten Binary Tree to Linked List
A

some crazy ass prev shit LOOK OVER AGAIN FOR SURE

161
Q
  1. Find Smallest Letter Greater Than Target
A

e

162
Q
  1. Expression Add Operators
A

e

163
Q

122 Buy sell stock

A

I remembered somehow, understand the peak-valley deal

164
Q

118 Pascals Triangle

A

look at fucking return types, had to change whole thing

165
Q
  1. Best Time to Buy and Sell Stock with Cooldown
A

state machine, iterpreting into dp code, optimizing. very good, look at generalization article too

166
Q
  1. Remove Duplicates from Sorted Array
A

Good job altering from original plan to most efficient possible algo! (Beats 100%)

167
Q
  1. Word Break II
A

e

168
Q
  1. Word Search II
A

DO OPTIMIZATION: its in the solution code in a comment.

169
Q
  1. Binary Tree Right Side View
A

DO RECURSION METHOD (reverse pre-order) I got the level order bfs queue version.

170
Q
  1. Permutations
A

list concatenation is O(n). list slicing is O(n). Use hashset to be faster than checking if it exists in a list. Time complexity would be O(n!*n) with list checking. O(n!) w/ set space is O(n!) bc of res.

171
Q
  1. Intersection of two Linked Lists
A

hashset soln if not find other one can have stop condition be while(nodeA != nodeB) bc they will both be null at some point

172
Q
  1. Graph Valid Tree
A

e

173
Q
  1. Find Peak Element
A

there are some sneaky things with bisearch that ppl solns did, mine is easy to understand but has more lines, later attempt to implement those sneaky things if you see them a lot more? also RECURSIVE VERSION

174
Q
  1. Average of Levels in Binary Tree
A

Iterative BFS done. Do recursive/DFS

175
Q
  1. Trapping Rain Water
A

Key Takeaway: even on LC Hard, the fundemental idea you need in order to solve the problem is not too outrageous: min(maxleft, maxright) - curheight basically, don’t think its not possible NEXT: UNDERSTAND STACK SOLUTION!!

176
Q
  1. Game of Life
A

implement it

177
Q
  1. Find All Anagrams in a String
A

Sliding window, plan on memorizing this shit real good

178
Q
  1. Insert Delete GetRandom O(1)
A

get it or u dont, hint: -swap-

179
Q

15 3Sum

A

super annoying implementation, needing to protect agianst dups just gross

180
Q
  1. Group Anagrams
A

learned defaultdict, using tuples

181
Q
  1. 3Sum Closest
A

Once find target, return immediately :)

182
Q
  1. Peak Index in a Mountain Array
A

peak finding

183
Q

268 Missing Number

A

I thought about doing the sum thing ;0 ;0 ;0 should have thought more ://

184
Q
  1. Merge k Sorted Lists
A

e

185
Q

191 Nubmer of 1 bits

A

nice

186
Q
  1. Closest Binary Search Tree Value
A

e

187
Q
  1. Reverse Integer
A

Negative modulus Overflow cycles hella, cant rely on just being less than or greater than previous number. must check if not equal to previous number

188
Q
  1. Non-overlapping Intervals
A

I did sort by first element, best is sort by second

189
Q
  1. Remove Linked List Elements
A

e

190
Q
  1. Gas Station
A

e

191
Q
  1. Integer to English Words
A

e

192
Q
  1. Number of Connected Components in an Undirected Graph
A

e

193
Q

108 Convert Sorted Array to BST

A

edge case len = 0

194
Q

48 Rotate Image

A

ctci

195
Q
  1. Add and Search Word - Data structure design
A

e

196
Q
  1. Lowest Common Ancestor of a Binary Search Tree
A

try again, iterative too

197
Q
  1. Reorder List
A

neat most recent submission

198
Q
  1. Construct Binary Tree from Preorder and Inorder Traversal
A

bisearch on tree kinda Do java soln to avoid splice time creating new lists from that python guy

199
Q
  1. Find All Duplicates in an Array
A

e

200
Q
  1. Rotate List
A

nice

201
Q

326 Power of three

A

smokeout

202
Q
  1. Implement Stack using Queues
A

e

203
Q
  1. Search in Rotated Sorted Array II
A

e

204
Q
  1. House Robber III
A

GENERALLY PASS UP INFORMATION. I tried passing down info, and not good recursive practice. Try to say, given the info of node below, what do I do now? Instead of passing info about current problem down to below problem, actually its just top-down vs bottom-up. ACTUALLY IDK, KEEP A LOOK OUT FOR THIS AND COME BACK. SEE IF OPINION CHANGES

205
Q
  1. Restore IP Addresses
A

e

206
Q
  1. Course Schedule II
A

e

207
Q
  1. Recover Binary Search Tree
A

e

208
Q
  1. 4Sum II
A

pretty simple actually

209
Q
  1. Subarray Sum Equals K
A

looks like sliding window, but actually presum + 2 sum very cool stuff

210
Q
  1. LRU Cache
A

e

211
Q
  1. Add Two Numbers II
A

e

212
Q
  1. Max Depth of BST
A

e

213
Q
  1. Prison Cells After N Days
A

e

214
Q

234 Palindrome Linked List

A

really good, optimization and clean code should be attempted next time!! I like my solution the best actually, most recent submission has cleaner for-loops than first 2nd attemp soln

215
Q

206 Reverse Linked List

A

try recursive next time,also only need 2 temps to start

216
Q
  1. Longest Duplicate Substring
A

e

217
Q

387 First unique character in string

A

I traversed wrong array for second loop…. dumb boy..

218
Q
  1. Hamming Distance
A

many ways to do

219
Q
  1. Pacific Atlantic Water Flow
A

try bfs, direction thing too

220
Q
  1. Path Sum II
A

backtracking aspect. Really good point on BFS vs DFS here in solution article. Take note of this Time complexity

221
Q
  1. Odd Even Linked List
A

got it

222
Q
  1. Swap Nodes in Pairs
A

recursive soln next

223
Q
  1. Partition Equal Subset Sum
A

0/1 knapsack

224
Q

230 Kth Smallest Element

A

inorder traverse ez, python global vars n shi try iteration? DO FOLLOW-UP SIMILAR TO LRU CACHE

225
Q
  1. Minimum Window Substring
A

time space linear

226
Q
  1. String Compression
A

e

227
Q
  1. Partition Labels
A

e

228
Q
  1. Monotonic Array
A

e

229
Q
  1. Continuous Subarray Sum
A

e

230
Q
  1. Longest Repeating Character Replacement
A

Can get O(n) by never shrinking the window

231
Q

53 Maximum Subarray

A

memorize algo

232
Q
  1. All Nodes Distance K in Binary Tree
A

Build a graph out of the tree, then BFS. Try other solution w/o creating graph

233
Q
  1. Implement Str()str()
A

only traverse haystack.length() - needle.length()+1 use i + j instead of h and use 2nd for loop for ease

234
Q
  1. Longest Substring with At Most Two Distinct Characters
A

NOTE IMPORTANT****: DO OPTIMIZED SOLUTION.

235
Q
  1. Design Search Autocomplete System
A

e

236
Q
  1. Find Median from Data Stream
A

BST solution, list solution, 2 heaps solution

237
Q
  1. Word Ladder II
A

e

238
Q

202 Happy Number

A

Gucci (Edit months later: No. u are not gucci u idiot ahaha)

239
Q
  1. Shortest Unsorted Continuous Subarray
A

hard array…

240
Q
  1. Longest Increasing Subsequence
A

dp, also nlogn unnecessary tho

241
Q
  1. Serialize and Deserialize N-ary Tree
A

e

242
Q
  1. Top K Frequent Elements
A

ATTENTION: NOW SWITCHING TO PYTHON LOLOLOLOL bucket sort

243
Q
  1. Linked List Cycle II
A

e

244
Q
  1. Backspace String Compare
A

e

245
Q
  1. Search a 2D Matrix II
A

implement it

246
Q
  1. Sort Colors
A

3 ptr basically or 2 ptr + iteration Tags: quicksort partition

247
Q
  1. Middle of the Linked List
A

e

248
Q
  1. Subarray Product Less Than K
A

e

249
Q
  1. Perfect Squares
A

bfs and dp, implement it

250
Q
  1. Meeting Rooms II
A

e

251
Q
  1. Next Permutation
A

e

252
Q
  1. Generate Parentheses
A

Errors having to do both with understanding stringbuilder class: initialize with string “(“ NOT ‘(‘ Understand why deleteChar(i) after each append :) CONDENSE THAT SHIT (I like my soln, try to condense it continuing using SB, with the given solution’s if statements) most recent submission is hype

253
Q
  1. Lowest Common Ancestor of a Binary Tree
A

Do iterative

254
Q
  1. Inorder Successor in BST II
A

e

255
Q
  1. Sum of Two Integers
A

e

256
Q
  1. Minimum Cost to Connect Sticks
A

e

257
Q
  1. Climbing Stairs
A

dp, fibonnaci nice

258
Q
  1. Find All Numbers Disappeared in an Array
A

negation shit stupid

259
Q

238 Product of Array Except Self

A

try in constance time follow up, not very different from linear time

260
Q

350 Intersections of two arrays II

A

e

261
Q
  1. Increasing Triplet Subsequence
A

reducing to 3’s, means using that info to reduce time. Like sorting color too.

262
Q
  1. Maximum Swap
A

e

263
Q
  1. Add Strings
A

e

264
Q
  1. Missing Element in Sorted Array
A

e

265
Q
  1. Reverse Linked List II
A

I like my soln the best, most intuitive

266
Q
  1. Min Stack
A

useful prob

267
Q
  1. Rotate Array
A

tried and failed miserably to do in place Reason I failed: checking if the values were equivalent rather than looking at the indexes. Soln: if reach same starting idx, just look at the next idx and go through that loop, THATs the stopping condition, when n swaps! got the extra space soln tho

268
Q
  1. Maximum Sum of 3 Non-Overlapping Subarrays
A

e

269
Q
  1. Binary Tree Level Order Traversal II
A

Do Recursive next

270
Q
  1. Roman to Integer
A

store vals better (hash or array), add all accross and then subtract if necessary, ask if it will always be valid! then, dont need each case

271
Q
  1. Evaluate Reverse Polish Notation
A

e