Skip to content

A small project to train data-structures and algorithms daily

Notifications You must be signed in to change notification settings

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
1 A. Numbers Codeforces 1.cpp math
2 A. Fashion in Berland Codeforces 2.cpp logic
3 A. Night at the Museum Codeforces 3.cpp logic
4 A. Bear and Game Codeforces 4.cpp logic
5 A. Arrays Codeforces 5.cpp sort
6 A. Vitaly and Strings Codeforces 6.cpp logic
7 B. African Crossword Codeforces 7.cpp logic
8 B. Big Segment Codeforces 8.cpp logic
9 B. Passwords Codeforces 9.cpp math
10 A. Dress'em in Vests! Codeforces 10.cpp logic
11 A. Sereja and Dima Codeforces 11.cpp logic
12 B. Approximating a Constant Range Codeforces 12.cpp 2-pointers
13 B. Array Codeforces 13.cpp 2-pointers
14 B. Balls Game Codeforces 14.cpp 2-pointers
15 B. Books Codeforces 15.cpp 2-pointers
16 B. George and Round Codeforces 16.cpp 2-pointers
17 C. Alice, Bob and Chocolate Codeforces 17.cpp 2-pointers
18 A. Business trip Codeforces 18.cpp sort
19 A. Chores Codeforces 19.cpp sort
20 A. GukiZ and Contest Codeforces 20.cpp sort
21 A. Towers Codeforces 21.cpp logic
22 B. Devu, the Dumb Guy Codeforces 22.cpp sort
23 B. Eight Point Sets Codeforces 23.cpp sort, logic
24 B. Pasha and Tea Codeforces 24.cpp sort, logic
25 B. Sort the Array Codeforces 25.cpp sort, logic, 2-pointers
26 Compilers and parsers Codechef 26.cpp greedy
27 MMASS - Mass of Molecule SPOJ 27.cpp stack
28 STPAR - Street Parade SPOJ 28.cpp stack
29 ONP - Transform the Expression SPOJ 29.cpp stack
30 10935 - Throwing cards away I UVA 30.cpp queue
31 12207 - That is Your Queue UVA 31.cpp queue
32 10901 - Ferry Loading III UVA 32.cpp queue
33 UCV2013H - Slick SPOJ 33.py bfs
34 MAKEMAZE - VALIDATE THE MAZE SPOJ 34.py bfs
35 Guilty Prince LightOJ 35.py bfs
36 Dhoom 4 HackerEarth 36.py bfs
37 Breadth First Search: Shortest Reach HackerRank 37.py bfs
38 C. Ice Cave Codeforces 38.py bfs
39 Valid Parentheses LeetCode 39.py logic
40 C. Kefa and Park Codeforces 40.py bfs
41 1610 - Dudu Service Maker UVA 41.py dfs
42 D. Lakes in Berland Codeforces 42.py dfs
43 CAM5 - prayatna PR SPOJ 43.cpp dfs
44 BENEFACT - The Benefactor SPOJ 44.py dfs
45 LASTSHOT - THE LAST SHOT SPOJ 45.go dfs
46 10954 - Add All UVA 46.py heap
47 11995 - I Can Guess the Data Structure! UVA 47.py heap, stack,queue
48 Monk and Multiplication HackerEarth 48.py heap
49 QHEAP1 HackerRank 49.py heap
50 Restaurant Rating CodeChef 50.py heap
51 Roy and Trending Topics HackerEarth 51.py heap
52 Two Sum LeetCode 52.py logic
53 Ransom Note LeetCode 53.py logic
54 Best Time to Buy and Sell Stock II LeetCode 54.py logic
55 Palindrome Number LeetCode 55.py logic
56 Roman to Integer LeetCode 56.py logic
57 Longest Common Prefix LeetCode 57.py sort
58 Summary Ranges LeetCode 58.py logic
59 Equal Row and Column Pairs LeetCode 59.py hash
60 Minimum Absolute Difference in BST LeetCode 60.py dfs
61 Maximum Level Sum of a Binary Tree LeetCode 61.py dfs
62 Bishu and his Girlfriend HackerEarth 62.cpp dfs
63 ALLIZWEL - ALL IZZ WELL SPOJ 63.py dfs
64 1726. Tuple with Same Product LeetCode 64.py sorting, 2-pointers, math
65 2. Add Two Numbers LeetCode 65.py linked-list
66 4. Median of Two Sorted Arrays LeetCode 66.py sort
67 3. Longest Substring Without Repeating Characters LeetCode 67.py 2-pointers
68 2576. Find the Maximum Number of Marked Indices LeetCode 68.py 2-pointers, sort
69 966. Vowel Spellchecker LeetCode 69.py logic
70 2239. Find Closest Number to Zero LeetCode 70.py logic
71 3160. Find the Number of Distinct Colors Among the Balls LeetCode 71.py queue, dict
72 3043. Find the Length of the Longest Common Prefix LeetCode 72.py trie
73 TRVCOST - Travelling cost SPOJ 73.py dijkstra
74 MICEMAZE - Mice and Maze SPOJ 74.py dijkstra
75 SHPATH - The Shortest Path SPOJ 75.cpp dijkstra
76 10986 - Sending email UVA 76.py dijkstra
77 Commandos LightOJ 77.cpp dijkstra
78 TRAFFICN - Traffic Network SPOJ 78.cpp dijkstra
79 558 - Wormholes UVA 79.py bellman
80 Extended Traffic LightOJ 80.cpp bellman
81 UCV2013B - Alice in Amsterdam, I mean Wonderland SPOJ 81.cpp bellman
82 Monk's Business Day HackerRank 82.py bellman
83 515. Find Largest Value in Each Tree Row LeetCode 83.py sort, binary-tree
84 ARBITRAG - Arbitrage SPOJ 84.py floy-warshall
85 278. First Bad Version LeetCode 85.py binary-search
86 10171 - Meeting Prof. Miguel... UVA 86.py floy-warshall
87 10246 - Asterix and Obelix UVA 87.py floy-warshall
88 2349. Design a Number Container System LeetCode 88.py heap
89 2364. Count Number of Bad Pairs LeetCode 89.py logic, math
90 3174. Clear Digits LeetCode 90.py stack
91 3289. The Two Sneaky Numbers of Digitville LeetCode 91.py logic
92 2739. Total Distance Traveled LeetCode 92.py logic
93 1910. Remove All Occurrences of a Substring LeetCode 93.py stack
94 2816. Double a Number Represented as a Linked List LeetCode 94.py linked-list
95 2342. Max Sum of a Pair With Equal Sum of Digits LeetCode 95.py logic
96 3066. Minimum Operations to Exceed Threshold Value II LeetCode 96.py heap
97 1352. Product of the Last K Numbers LeetCode 97.py logic
98 2698. Find the Punishment Number of an Integer LeetCode 98.py recursive
99 1718. Construct the Lexicographically Largest Valid Sequence LeetCode 99.py recursive
100 1079. Letter Tile Possibilities LeetCode 100.py back-tracking, set $$O(n \cdot n!)$$
101 2375. Construct Smallest Number From DI String LeetCode 101.py back-tracking, set $$O(n \cdot n!)$$
102 1415. The k-th Lexicographical String of All Happy Strings of Length n LeetCode 102.py back-tracking, set, sort $$O(n!)$$
103 1980. Find Unique Binary String LeetCode 103.py back-tracking $$O(n!)$$
104 1261. Find Elements in a Contaminated Binary Tree LeetCode 104.py back-tracking $$O(n)$$
105 3325. Count Substrings With K-Frequency Characters I LeetCode 105.py logic $$O(n)$$
106 ⭐ 1028. Recover a Tree From Preorder Traversal LeetCode 106.py bin-tree, back-tracking $$O(n)$$
107 ⭐ 889. Construct Binary Tree from Preorder and Postorder Traversal LeetCode 107.py bin-tree, back-tracking $$O(n^2)$$
108 ⭐ 2467. Most Profitable Path in a Tree LeetCode 108.py dfs $$O(n)$$
109 21. Merge Two Sorted Lists LeetCode 109.java logic $$O(n)$$
110 35. Search Insert Position LeetCode 110.js binary-search $$O(log(n))$$
111 ⭐ 1524. Number of Sub-arrays With Odd Sum LeetCode 111.py dp $$O(n)$$
112 ⭐ 1749. Maximum Absolute Sum of Any Subarray LeetCode 112.py greedy $$O(n)$$
113 ⭐ 873. Length of Longest Fibonacci Subsequence LeetCode 113.go dp $$O(n^2)$$
114 ⭐ 1092. Shortest Common Supersequence LeetCode 114.py dp $$O(n \cdot m)$$
115 2460. Apply Operations to an Array LeetCode 115.go logic $$O(n)$$
116 2570. Merge Two 2D Arrays by Summing Values LeetCode 116.js logic $$O(m + n)$$
117 2161. Partition Array According to Given Pivot LeetCode 117.ts logic $$O(n)$$
118 1780. Check if Number is a Sum of Powers of Three LeetCode 118.js logic $$O(16)$$
119 2579. Count Total Number of Colored Cells LeetCode 119.go logic $$O(n / 2)$$
120 2965. Find Missing and Repeated Values LeetCode 120.py logic $$O(n^2)$$
121 2523. Closest Prime Numbers in Range LeetCode 121.go logic $$O(n\cdot log(log(n)))$$
122 2379. Minimum Recolors to Get K Consecutive Black Blocks LeetCode 122.go logic $$O(n)$$
123 876. Middle of the Linked List LeetCode 123.go logic $$O(n)$$
124 3208. Alternating Groups II LeetCode 124.js 2-pointers $$O(n + k)$$
125 1358. Number of Substrings Containing All Three Characters LeetCode 125.py slide-window $$O(n)$$
126 2529. Maximum Count of Positive Integer and Negative Integer LeetCode 126.py logic $$O(n)$$
127 3306. Count of Substrings Containing Every Vowel and K Consonants II LeetCode 127.py slide-window $$O(n)$$
128 88. Merge Sorted Array LeetCode 128.py sort $$O(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$
130 ⭐ 3356. Zero Array Transformation II LeetCode 130.py binary-search $$O(n log(n))$$
131 ⭐ 2560. House Robber IV LeetCode 131.py binary-search $$O(n log(n))$$
132 ⭐ 2594. Minimum Time to Repair Cars LeetCode 132.java binary-search $$O(n log(n))$$
133 2206. Divide Array Into Equal Pairs LeetCode 133.java logic $$O(max(n, 500))$$
134 1976. Number of Ways to Arrive at Destination LeetCode 134.py dijkstra $$O((N + E)log(N))$$
135 2685. Count the Number of Complete Components LeetCode 135.py dfs $$O(n+mlogn) \text{ and } O(n+m)$$
136 2033. Minimum Operations to Make a Uni-Value Grid LeetCode 136.py sort, math $$O(n \cdot logn)$$
137 2780. Minimum Index of a Valid Split LeetCode 137.py logic $$O(n)$$
138 3169. Count Days Without Meetings LeetCode 138.py sort $$O(log(n))$$
139 3191. Minimum Operations to Make Binary Array Elements Equal to One I LeetCode 139.py sliding-window $$O(n)$$
140 2401. Longest Nice Subarray LeetCode 140.py sliding-window $$O(n)$$
141 ⭐ 763. Partition Labels LeetCode 141.py 2-pointers $$O(n)$$
142 ⭐ 2140. Solving Questions With Brainpower LeetCode 142.py dp $$O(n)$$
143 2874. Maximum Value of an Ordered Triplet II LeetCode 143.py greedy $$O(n)$$
144 1123. Lowest Common Ancestor of Deepest Leaves LeetCode 144.py dfs, backtracking $$O(n)$$
145 1863. Sum of All Subset XOR Totals LeetCode 145.py backtracking $$O(2^n)$$
146 198. House Robber LeetCode 146.py dp $$O(n)$$
147 368. Largest Divisible Subset LeetCode 147.py dp $$O(n^2)$$
148 416. Partition Equal Subset Sum LeetCode 148.py dp $$O(n^2)$$
149 2843. Count Symmetric Integers LeetCode 149.py logic $$O(n)$$
150 3396. Minimum Number of Operations to Make Elements in Array Distinct LeetCode 150.java logic $$O(n)$$

About

A small project to train data-structures and algorithms daily

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages