Skip to content

Commit ab5aa5c

Browse files
committed
January 25
1 parent e6b1905 commit ab5aa5c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ Solutions <a href = "https://github.com/aliasvishnu/leetcode/tree/master/Solutio
134134
| 261 | DFS | If any chain of exploration hits an already visited node, return false. | O(n) |
135135
| 263 | BF | Divide by 2, 3, 5. You should have 1 in the end. | O(log(n)) in terms of bits. |
136136
| 264 | BF | There are 3 sequences 2x1, 2x2, 2x3....; 3x1, 3x2, 3x3, ...; 5x1, 5x2, 5x3 ...; Keep 3 pointers, at each step, each of these pointers will give the next candidate. The minimum candidate is the next ugly number. | O(n) |
137-
|
137+
| 265 | BF/Greedy | M[i][j] = cost of painting first i house and i is painted in color j. Fill it it in a bottom up fashion. | O(n^2) |
138+
| 266 | BF | Keep count of letters. | O(n) |
139+
| 269 | Topological Sort | Construct the mapping using the dictionary, then do topological sorting. | O(n*max(word_length)) |
140+
| 270 | BST | Root to leaf search. | O(log(n)) |
141+
| 271 | Array | Use string length to keep track. | O(n), n=total number of characters |
142+
| 272 |
138143
| 413 | Array | [1, 2, 3, 4, 5, 7, 9, 11]. can be written as [5, 3] i.e. 5 sequence of difference 1 and 3 sequence of difference 2, you need to figure out how many parts you can split 5 and 3 into. | O(n) |
139144
| 694 | DFS | Keep track of the directions in which DFS proceeds in some form, maybe a string like ddr for down down right. | O(rows*cols) |
140145
| 738 | Array | Find the first time Xi > Xi+1, Xi -= 1 and turn all Xi+k = 9, For eg, 321 becomes 299. Figure out cases like 33332. | O(n) |

Solutions/269-AlienDictionary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Solution {
2121
}
2222

2323
void createGraph(vector<string> words){
24-
vector<char> fl;
24+
vector<char> fl; // firstLetter
2525
unordered_map<char, vector<string>> mp;
2626

2727
for(string word: words){

0 commit comments

Comments
 (0)