Skip to content

cuongpiger/algorithms-training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Hi guys, I'm Cuong 👋.

⬇️ No. Problem Title Organization Solution Algorithm Time Complexity
218 206. Reverse Linked List LeetCode 218.py linked-list $$O(n)$$
217 💜 205. Isomorphic Strings LeetCode 217.py string $$O(n)$$
216 203. Remove Linked List Elements LeetCode 216.py linked-list $$O(n)$$
215 202. Happy Number LeetCode 215.py math $$O(1)$$
214 197. Rising Temperature LeetCode 214.sql sql $$O(n)$$
213 196. Delete Duplicate Emails LeetCode 213.sql sql $$O(n)$$
212 195. Tenth Line LeetCode 212.sh shell $$O(n)$$
211 193. Valid Phone Numbers LeetCode 211.sh shell $$O(n)$$
210 191. Number of 1 Bits LeetCode 210.py bitwise $$O(\log n)$$
209 💜 190. Reverse Bits LeetCode 209.go bitwise $$O(1)$$
208 183. Customers Who Never Order LeetCode 208.sql sql $$O(n)$$
207 182. Duplicate Emails LeetCode 207.sql sql $$O(n)$$
206 181. Employees Earning More Than Their Managers LeetCode 206.sql sql $$O(n)$$
205 175. Combine Two Tables LeetCode 205.sql sql $$O(n)$$
204 💜 171. Excel Sheet Column Number LeetCode 204.py math $$O(n)$$
203 169. Majority Element LeetCode 203.py sorting $$O(n \log n)$$
202 💜 168. Excel Sheet Column Title LeetCode 202.py math $$O(\log n)$$
201 160. Intersection of Two Linked Lists LeetCode 201.py linked-list $$O(n + m)$$
200 145. Binary Tree Postorder Traversal LeetCode 200.go tree $$O(n)$$
199 144. Binary Tree Preorder Traversal LeetCode 199.py tree $$O(n)$$
198 ⭐ 141. Linked List Cycle LeetCode 198.py linked-list $$O(n)$$
197 ⭐ 136. Single Number LeetCode 197.ts bitwise $$O(n)$$
196 125. Valid Palindrome LeetCode 196.js string $$O(n)$$
195 💜 121. Best Time to Buy and Sell Stock LeetCode 195.go array $$O(n)$$
194 119. Pascal's Triangle II LeetCode 194.py array $$O(2^n)$$
193 118. Pascal's Triangle LeetCode 193.py array $$O(2^n)$$
192 112. Path Sum LeetCode 192.py tree $$O(n)$$
191 111. Minimum Depth of Binary Tree LeetCode 191.py tree $$O(n)$$
190 ⭐ 110. Balanced Binary Tree LeetCode 190.py tree $$O(n)$$
189 108. Convert Sorted Array to Binary Search Tree LeetCode 189.py tree $$O(n)$$
188 104. Maximum Depth of Binary Tree LeetCode 188.py tree $$O(n)$$
187 101. Symmetric Tree LeetCode 187.py tree $$O(n)$$
186 100. Same Tree LeetCode 186.py tree $$O(n)$$
185 94. Binary Tree Inorder Traversal LeetCode 185.py tree $$O(n)$$
184 83. Remove Duplicates from Sorted List LeetCode 184.py linked-list $$O(n)$$
183 70. Climbing Stairs LeetCode 183.py dp $$O(n)$$
182 69. Sqrt(x) LeetCode 182.py binary-search $$O(\log n)$$
181 67. Add Binary LeetCode 181.py string $$O(n)$$
180 66. Plus One LeetCode 180.py array $$O(n)$$
179 58. Length of Last Word LeetCode 179.py array $$O(n)$$
178 28. Find the Index of the First Occurrence in a String LeetCode 178.py string $$O(n \cdot m)$$
177 27. Remove Element LeetCode 177.py 2-pointers $$O(n)$$
176 26. Remove Duplicates from Sorted Array LeetCode 176.py array $$O(n)$$
175 2131. Longest Palindrome by Concatenating Two Letter Words LeetCode 175.py math $$O(n)$$
174 2942. Find Words Containing Character LeetCode 174.py math $$O(n \cdot max(length(word)))$$
173 3024. Type of Triangle LeetCode 173.py math $$O(1)$$
172 75. Sort Colors LeetCode 172.py array $$O(n)$$
171 3335. Total Characters in String After Transformations I LeetCode 171.ts array $$O(max(n, t))$$
170 2094. Finding 3-Digit Even Numbers LeetCode 170.ts array $$O(n^3)$$
169 1550. Three Consecutive Odds LeetCode 169.ts array $$O(n)$$
168 3341. Find Minimum Time to Reach Last Room I LeetCode 168.py dijsktra $$O(mn \cdot \log{mn})$$
167 ⭐ 790. Domino and Tromino Tiling LeetCode 167.py dp $$O(n)$$
166 1920. Build Array from Permutation LeetCode 166.ts logic $$O(n)$$
165 1128. Number of Equivalent Domino Pairs LeetCode 165.ts logic $$O(n)$$
164 1007. Minimum Domino Rotations For Equal Row LeetCode 164.ts logic $$O(n)$$
163 838. Push Dominoes LeetCode 163.py logic $$O(n)$$
162 ⭐ 2071. Maximum Number of Tasks You Can Assign LeetCode 162.py binary-search $$O(\max(nlogn, mlogm) + \min(m, n) \cdot \log_{2}{min(m, n)})$$
161 1399. Count Largest Group LeetCode 161.ts hash-map $$O(n \cdot \log_{10}{n})$$
160 2799. Count Complete Subarrays in an Array LeetCode 160.ts sliding-window $$O(n)$$
159 2845. Count of Interesting Subarrays LeetCode 159.ts prefix-sum $$O(n)$$
158 1534. Count Good Triplets LeetCode 158.ts logic $$O(n^3)$$
157 1295. Find Numbers with Even Number of Digits LeetCode 157.ts recursive $$O(n \cdot \log_{10}{m})$$
with $m$ is the maximum value in the given array $nums$
156 ⭐ 2962. Count Subarrays Where Max Element Appears at Least K Times LeetCode 156.py sliding-window $$O(n)$$
155 2302. Count Subarrays With Score Less Than K LeetCode 155.py sliding-window $$O(n)$$
154 3392. Count Subarrays of Length Three With a Condition LeetCode 154.py sliding-window $$O(n)$$
153 1399. Count Largest Group LeetCode 153.py hashmap $$O(nlogn)$$
152 38. Count and Say LeetCode 152.py backtracking $$O(2^n)$$
151 ⭐ 1922. Count Good Numbers LeetCode 151.py fast-exponentiation $$O(logn)$$
150 3396. Minimum Number of Operations to Make Elements in Array Distinct LeetCode 150.java logic $$O(n)$$
149 2843. Count Symmetric Integers LeetCode 149.py logic $$O(n)$$
148 416. Partition Equal Subset Sum LeetCode 148.py dp $$O(n^2)$$
147 368. Largest Divisible Subset LeetCode 147.py dp $$O(n^2)$$
146 198. House Robber LeetCode 146.py dp $$O(n)$$
145 1863. Sum of All Subset XOR Totals LeetCode 145.py backtracking $$O(2^n)$$
144 1123. Lowest Common Ancestor of Deepest Leaves LeetCode 144.py dfs, backtracking $$O(n)$$
143 2874. Maximum Value of an Ordered Triplet II LeetCode 143.py greedy $$O(n)$$
142 ⭐ 2140. Solving Questions With Brainpower LeetCode 142.py dp $$O(n)$$
141 ⭐ 763. Partition Labels LeetCode 141.py 2-pointers $$O(n)$$
140 2401. Longest Nice Subarray LeetCode 140.py sliding-window $$O(n)$$
139 3191. Minimum Operations to Make Binary Array Elements Equal to One I LeetCode 139.py sliding-window $$O(n)$$
138 3169. Count Days Without Meetings LeetCode 138.py sort $$O(log(n))$$
137 2780. Minimum Index of a Valid Split LeetCode 137.py logic $$O(n)$$
136 2033. Minimum Operations to Make a Uni-Value Grid LeetCode 136.py sort, math $$O(n \cdot logn)$$
135 2685. Count the Number of Complete Components LeetCode 135.py dfs $$O(n+mlogn) \text{ and } O(n+m)$$
134 1976. Number of Ways to Arrive at Destination LeetCode 134.py dijkstra $$O((N + E)log(N))$$
133 2206. Divide Array Into Equal Pairs LeetCode 133.java logic $$O(max(n, 500))$$
132 ⭐ 2594. Minimum Time to Repair Cars LeetCode 132.java binary-search $$O(n log(n))$$
131 ⭐ 2560. House Robber IV LeetCode 131.py binary-search $$O(n log(n))$$
130 ⭐ 3356. Zero Array Transformation II LeetCode 130.py binary-search $$O(n log(n))$$
129 2226. Maximum Candies Allocated to K Children LeetCode 129.py binary-search $$O(n log(m))$$
with $m$ is the maximum value in the array $candies$, and $n$ is the length of $candies$
128 88. Merge Sorted Array LeetCode 128.py sort $$O(log(n))$$
127 3306. Count of Substrings Containing Every Vowel and K Consonants II LeetCode 127.py slide-window $$O(n)$$
126 2529. Maximum Count of Positive Integer and Negative Integer LeetCode 126.py logic $$O(n)$$
125 1358. Number of Substrings Containing All Three Characters LeetCode 125.py slide-window $$O(n)$$
124 3208. Alternating Groups II LeetCode 124.js 2-pointers $$O(n + k)$$
123 876. Middle of the Linked List LeetCode 123.go logic $$O(n)$$
122 2379. Minimum Recolors to Get K Consecutive Black Blocks LeetCode 122.go logic $$O(n)$$
121 2523. Closest Prime Numbers in Range LeetCode 121.go logic $$O(n\cdot log(log(n)))$$
120 2965. Find Missing and Repeated Values LeetCode 120.py logic $$O(n^2)$$
119 2579. Count Total Number of Colored Cells LeetCode 119.go logic $$O(n / 2)$$
118 1780. Check if Number is a Sum of Powers of Three LeetCode 118.js logic $$O(16)$$
117 2161. Partition Array According to Given Pivot LeetCode 117.ts logic $$O(n)$$
116 2570. Merge Two 2D Arrays by Summing Values LeetCode 116.js logic $$O(m + n)$$
115 2460. Apply Operations to an Array LeetCode 115.go logic $$O(n)$$
114 ⭐ 1092. Shortest Common Supersequence LeetCode 114.py dp $$O(n \cdot m)$$
113 ⭐ 873. Length of Longest Fibonacci Subsequence LeetCode 113.go dp $$O(n^2)$$
112 ⭐ 1749. Maximum Absolute Sum of Any Subarray LeetCode 112.py greedy $$O(n)$$
111 ⭐ 1524. Number of Sub-arrays With Odd Sum LeetCode 111.py dp $$O(n)$$
110 35. Search Insert Position LeetCode 110.js binary-search $$O(log(n))$$
109 21. Merge Two Sorted Lists LeetCode 109.java logic $$O(n)$$
108 ⭐ 2467. Most Profitable Path in a Tree LeetCode 108.py dfs $$O(n)$$
107 ⭐ 889. Construct Binary Tree from Preorder and Postorder Traversal LeetCode 107.py bin-tree, back-tracking $$O(n^2)$$
106 ⭐ 1028. Recover a Tree From Preorder Traversal LeetCode 106.py bin-tree, back-tracking $$O(n)$$
105 3325. Count Substrings With K-Frequency Characters I LeetCode 105.py logic $$O(n)$$
104 1261. Find Elements in a Contaminated Binary Tree LeetCode 104.py back-tracking $$O(n)$$
103 1980. Find Unique Binary String LeetCode 103.py back-tracking $$O(n!)$$
102 1415. The k-th Lexicographical String of All Happy Strings of Length n LeetCode 102.py back-tracking, set, sort $$O(n!)$$
101 2375. Construct Smallest Number From DI String LeetCode 101.py back-tracking, set $$O(n \cdot n!)$$
100 1079. Letter Tile Possibilities LeetCode 100.py back-tracking, set $$O(n \cdot n!)$$
99 1718. Construct the Lexicographically Largest Valid Sequence LeetCode 99.py recursive
98 2698. Find the Punishment Number of an Integer LeetCode 98.py recursive
97 1352. Product of the Last K Numbers LeetCode 97.py logic
96 3066. Minimum Operations to Exceed Threshold Value II LeetCode 96.py heap
95 2342. Max Sum of a Pair With Equal Sum of Digits LeetCode 95.py logic
94 2816. Double a Number Represented as a Linked List LeetCode 94.py linked-list
93 1910. Remove All Occurrences of a Substring LeetCode 93.py stack
92 2739. Total Distance Traveled LeetCode 92.py logic
91 3289. The Two Sneaky Numbers of Digitville LeetCode 91.py logic
90 3174. Clear Digits LeetCode 90.py stack
89 2364. Count Number of Bad Pairs LeetCode 89.py logic, math
88 2349. Design a Number Container System LeetCode 88.py heap
87 10246 - Asterix and Obelix UVA 87.py floy-warshall
86 10171 - Meeting Prof. Miguel... UVA 86.py floy-warshall
85 278. First Bad Version LeetCode 85.py binary-search
84 ARBITRAG - Arbitrage SPOJ 84.py floy-warshall
83 515. Find Largest Value in Each Tree Row LeetCode 83.py sort, binary-tree
82 Monk's Business Day HackerRank 82.py bellman
81 UCV2013B - Alice in Amsterdam, I mean Wonderland SPOJ 81.cpp bellman
80 Extended Traffic LightOJ 80.cpp bellman
79 558 - Wormholes UVA 79.py bellman
78 TRAFFICN - Traffic Network SPOJ 78.cpp dijkstra
77 Commandos LightOJ 77.cpp dijkstra
76 10986 - Sending email UVA 76.py dijkstra
75 SHPATH - The Shortest Path SPOJ 75.cpp dijkstra
74 MICEMAZE - Mice and Maze SPOJ 74.py dijkstra
73 TRVCOST - Travelling cost SPOJ 73.py dijkstra
72 3043. Find the Length of the Longest Common Prefix LeetCode 72.py trie
71 3160. Find the Number of Distinct Colors Among the Balls LeetCode 71.py queue, dict
70 2239. Find Closest Number to Zero LeetCode 70.py logic
69 966. Vowel Spellchecker LeetCode 69.py logic
68 2576. Find the Maximum Number of Marked Indices LeetCode 68.py 2-pointers, sort
67 3. Longest Substring Without Repeating Characters LeetCode 67.py 2-pointers
66 4. Median of Two Sorted Arrays LeetCode 66.py sort
65 2. Add Two Numbers LeetCode 65.py linked-list
64 1726. Tuple with Same Product LeetCode 64.py sorting, 2-pointers, math
63 ALLIZWEL - ALL IZZ WELL SPOJ 63.py dfs
62 Bishu and his Girlfriend HackerEarth 62.cpp dfs
61 Maximum Level Sum of a Binary Tree LeetCode 61.py dfs
60 Minimum Absolute Difference in BST LeetCode 60.py dfs
59 Equal Row and Column Pairs LeetCode 59.py hash
58 Summary Ranges LeetCode 58.py logic
57 Longest Common Prefix LeetCode 57.py sort
56 Roman to Integer LeetCode 56.py logic
55 Palindrome Number LeetCode 55.py logic
54 Best Time to Buy and Sell Stock II LeetCode 54.py logic
53 Ransom Note LeetCode 53.py logic
52 Two Sum LeetCode 52.py logic
51 Roy and Trending Topics HackerEarth 51.py heap
50 Restaurant Rating CodeChef 50.py heap
49 QHEAP1 HackerRank 49.py heap
48 Monk and Multiplication HackerEarth 48.py heap
47 11995 - I Can Guess the Data Structure! UVA 47.py heap, stack,queue
46 10954 - Add All UVA 46.py heap
45 LASTSHOT - THE LAST SHOT SPOJ 45.go dfs
44 BENEFACT - The Benefactor SPOJ 44.py dfs
43 CAM5 - prayatna PR SPOJ 43.cpp dfs
42 D. Lakes in Berland Codeforces 42.py dfs
41 1610 - Dudu Service Maker UVA 41.py dfs
40 C. Kefa and Park Codeforces 40.py bfs
39 Valid Parentheses LeetCode 39.py logic
38 C. Ice Cave Codeforces 38.py bfs
37 Breadth First Search: Shortest Reach HackerRank 37.py bfs
36 Dhoom 4 HackerEarth 36.py bfs
35 Guilty Prince LightOJ 35.py bfs
34 MAKEMAZE - VALIDATE THE MAZE SPOJ 34.py bfs
33 UCV2013H - Slick SPOJ 33.py bfs
32 10901 - Ferry Loading III UVA 32.cpp queue
31 12207 - That is Your Queue UVA 31.cpp queue
30 10935 - Throwing cards away I UVA 30.cpp queue
29 ONP - Transform the Expression SPOJ 29.cpp stack
28 STPAR - Street Parade SPOJ 28.cpp stack
27 MMASS - Mass of Molecule SPOJ 27.cpp stack
26 Compilers and parsers Codechef 26.cpp greedy
25 B. Sort the Array Codeforces 25.cpp sort, logic, 2-pointers
24 B. Pasha and Tea Codeforces 24.cpp sort, logic
23 B. Eight Point Sets Codeforces 23.cpp sort, logic
22 B. Devu, the Dumb Guy Codeforces 22.cpp sort
21 A. Towers Codeforces 21.cpp logic
20 A. GukiZ and Contest Codeforces 20.cpp sort
19 A. Chores Codeforces 19.cpp sort
18 A. Business trip Codeforces 18.cpp sort
17 C. Alice, Bob and Chocolate Codeforces 17.cpp 2-pointers
16 B. George and Round Codeforces 16.cpp 2-pointers
15 B. Books Codeforces 15.cpp 2-pointers
14 B. Balls Game Codeforces 14.cpp 2-pointers
13 B. Array Codeforces 13.cpp 2-pointers
12 B. Approximating a Constant Range Codeforces 12.cpp 2-pointers
11 A. Sereja and Dima Codeforces 11.cpp logic
10 A. Dress'em in Vests! Codeforces 10.cpp logic
9 B. Passwords Codeforces 9.cpp math
8 B. Big Segment Codeforces 8.cpp logic
7 B. African Crossword Codeforces 7.cpp logic
6 A. Vitaly and Strings Codeforces 6.cpp logic
5 A. Arrays Codeforces 5.cpp sort
4 A. Bear and Game Codeforces 4.cpp logic
3 A. Night at the Museum Codeforces 3.cpp logic
2 A. Fashion in Berland Codeforces 2.cpp logic
1 A. Numbers Codeforces 1.cpp math

About

A small project to train data-structures and algorithms daily

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published