Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

241 Commits

Repository files navigation

Competitive Programming Solutions

A collection of solved competitive programming problems across multiple online judges.

📊 Stats

PlatformCount
LeetCode275 problems
UVA Online Judge245 solutions
LightOJ171 solutions
Codeforces212 contests + 1 gym
TopCoder55 problems
SPOJ20 solutions
Total979+

🔗 Online Judge Profiles

📑 Table of Contents


🟡 LeetCode

Array & Hashing

#Problem
11. Two Sum
2626. Remove Duplicates from Sorted Array
2727. Remove Element
3636. Valid Sudoku
4848. Rotate Image
4949. Group Anagrams
5353. Maximum Subarray
5454. Spiral Matrix
5858. Length of Last Word
5959. Spiral Matrix II
6666. Plus One
7373. Set Matrix Zeroes
8080. Remove Duplicates from Sorted Array II
8888. Merge Sorted Array
118118. Pascals Triangle
128128. Longest Consecutive Sequence
136136. Single Number
169169. Majority Element
189189. Rotate Array
205205. Isomorphic Strings
217217. Contains Duplicate
219219. Contains Duplicate II
238238. Product of Array Except Self
242242. Valid Anagram
268268. Missing Number
271271. Encode and Decode Strings
274274. H Index
283283. Move Zeroes
289289. Game of Life
290290. Word Pattern
299299. Bulls and Cows
347347. Top K Frequent Elements
350350. Intersection of Two Arrays II
383383. Ransom Note
387387. First Unique Character in a String
412412. Fizz Buzz
448448. Find All Numbers Disappeared in an Array
523523. Continuous Subarray Sum
560560. Subarray Sum Equals K
782782. Jewels and Stones
965965. Unique Email Addresses
11121112. Find Words That Can Be Formed By Characters
15801580. Shuffle the Array
20582058. Concatenation of Array
32513251. Maximum Area of Longest Diagonal Rectangle

Two Pointers

#Problem
1111. Container with Most Water
1515. 3Sum
1616. 3Sum Closest
125125. Valid Palindrome
167167. Two Sum II Input Array is Sorted
259259. 3Sum Smaller
344344. Reverse String
392392. Is Subsequence

Sliding Window

#Problem
33. Longest Substring Without Repeating Characters
3030. Substring with Concatenation of All Words
7676. Minimum Window Substring
159159. Longest Substring with At Most Two Distinct Characters
209209. Minimum Size Subarray Sum
239239. Sliding Window Maximum
424424. Longest Repeating Character Replacement
480480. Sliding Window Median
485485. Max Consecutive Ones
539539. Minimum Time Difference
940940. Fruit Into Baskets
10341034. Subarrays with K Different Integers
10461046. Max Consecutive Ones III
13701370. Count Number of Nice Subarrays

Stack & Queue

#Problem
2020. Valid Parentheses
7171. Simplify Path
150150. Evaluate Reverse Polish Notation
155155. Min Stack
394394. Decode String
503503. Next Greater Element II
678678. Valid Parenthesis String
860860. Design Circular Queue
874874. Backspace String Compare
943943. Sum of Subarray Minimums
22272227. Sum of Subarray Ranges

Binary Search

#Problem
44. Median of Two Sorted Arrays
3333. Search in Rotated Sorted Array
3434. Find First and Last Position of Element in Sorted Array
153153. Find Minimum in Rotated Sorted Array
154154. Find Minimum in Rotated Sorted Array II
278278. First Bad Version
410410. Split Array Largest Sum
668668. Kth Smallest Number in Multiplication Table
882882. Peak Index in a Mountain Array

Linked List

#Problem
22. Add Two Numbers
1919. Remove Nth Node from End of List
2121. Merge Two Sorted Lists
2323. Merge K Sorted Lists
2525. Reverse Nodes in k-Group
138138. Copy List with Random Pointer
141141. Linked List Cycle
143143. Reorder List
160160. Intersection of Two Linked Lists
206206. Reverse Linked List
234234. Palindrome Linked List
237237. Delete Node in a Linked List
445445. Add Two Numbers II
908908. Middle of the Linked List

Tree

#Problem
9494. Binary Tree Inorder Traversal
9898. Validate Binary Search Tree
100100. Same Tree
101101. Symmetric Tree
102102. Binary Tree Level Order Traversal
103103. Binary Tree Zigzag Level Order Traversal
104104. Maximum Depth of Binary Tree
105105. Construct Binary Tree from Preorder and Inorder Traversal
106106. Construct Binary Tree from Inorder and Postorder Traversal
108108. Convert Sorted Array to Binary Search Tree
116116. Populating Next Right Pointers in Each Node
117117. Populating Next Right Pointers in Each Node II
124124. Binary Tree Maximum Path Sum
222222. Count Complete Tree Nodes
226226. Invert Binary Tree
230230. Kth Smallest Element in a BST
235235. Lowest Common Ancestor of a Binary Search Tree
236236. Lowest Common Ancestor of a Binary Tree
297297. Serialize and Deserialize Binary Tree
366366. Find Leaves of Binary Tree
449449. Serialize and Deserialize BST
450450. Delete Node in a BST
543543. Diameter of Binary Tree
572572. Subtree of Another Tree
784784. Insert Into a Binary Search Tree
988988. Flip Equivalent Binary Trees
22172217. Step By Step Directions from a Binary Tree Node to Another

Graph

#Problem
127127. Word Ladder
133133. Clone Graph
200200. Number of Islands
207207. Course Schedule
210210. Course Schedule II
261261. Graph Valid Tree
269269. Alien Dictionary
323323. Number of Connected Components in an Undirected Graph
399399. Evaluate Division
417417. Pacific Atlantic Water Flow
505505. The Maze II
675675. Cut Off Trees For Golf Event
733733. Flood Fill
984984. Most Stones Removed with Same Row or Column
989989. Largest Component Size By Common Factor
10361036. Rotting Oranges
14141414. Shortest Path in a Grid with Obstacles Elimination
22202220. Find All Possible Recipes from Given Supplies
24092409. Number of Increasing Paths in a Grid

Backtracking

#Problem
1717. Letter Combinations of a Phone Number
2222. Generate Parentheses
3131. Next Permutation
3939. Combination Sum
4040. Combination Sum II
4646. Permutations
4747. Permutations II
7777. Combinations
7878. Subsets
7979. Word Search
9090. Subsets II
131131. Palindrome Partitioning
212212. Word Search II
216216. Combination Sum III
247247. Strobogrammatic Number II
351351. Android Unlock Patterns
425425. Word Squares
681681. Next Closest Time
754754. Cracking the Safe
865865. Robot Room Cleaner

Dynamic Programming

#Problem
1010. Regular Expression Matching
4242. Trapping Rain Water
4444. Wildcard Matching
4545. Jump Game II
5555. Jump Game
6262. Unique Paths
7070. Climbing Stairs
9191. Decode Ways
121121. Best Time to Buy and Sell Stock
122122. Best Time to Buy and Sell Stock II
139139. Word Break
152152. Maximum Product Subarray
198198. House Robber
213213. House Robber II
300300. Longest Increasing Subsequence
322322. Coin Change
329329. Longest Increasing Path in a Matrix
516516. Longest Palindromic Subsequence
552552. Student Attendance Record II
836836. Race Car
855855. Count Unique Characters of All Substrings of a Given String
962962. Flip String to Monotone Increasing
10171017. Odd Even Jump
10421042. Minimum Cost to Merge Stones
11291129. Longest String Chain
11781178. Valid Palindrome III
12501250. Longest Common Subsequence
12631263. Number of Dice Rolls with Target Sum
14371437. Minimum Insertion Steps to Make a String Palindrome
16331633. Minimum Number of Increments On Subarrays to Form a Target Array
20672067. Maximum Number of Points with Cost
23602360. Substring with Largest Variance

Greedy

#Problem
134134. Gas Station
135135. Candy
435435. Non Overlapping Intervals
452452. Minimum Number of Arrows to Burst Balloons
621621. Task Scheduler
768768. Partition Labels
13041304. Longest Happy String

Intervals

#Problem
5656. Merge Intervals
5757. Insert Interval
163163. Missing Ranges
228228. Summary Ranges
252252. Meeting Rooms
253253. Meeting Rooms II

String

#Problem
55. Longest Palindromic Substring
66. Zigzag Conversion
77. Reverse Integer
88. String to Integer atoi
1212. Integer to Roman
1313. Roman to Integer
1414. Longest Common Prefix
2828. Find the Index of the First Occurrence in a String
4343. Multiply Strings
6868. Text Justification
151151. Reverse Words in a String
165165. Compare Version Numbers
166166. Fraction to Recurring Decimal
186186. Reverse Words in a String II
246246. Strobogrammatic Number
273273. Integer to English Words
482482. License Key Formatting
647647. Palindromic Substrings
793793. Swap Adjacent in LR String
827827. Expressive Words
837837. Most Common Word
862862. Find and Replace in String
974974. Reorder Data in Log Files

Bit Manipulation

#Problem
190190. Reverse Bits
191191. Number of 1 Bits
326326. Power of Three
338338. Counting Bits
371371. Sum of Two Integers
461461. Hamming Distance

Math & Geometry

#Problem
202202. Happy Number
204204. Count Primes
976976. Minimum Area Rectangle
22682268. Remove All Ones with Row and Column Flips

Design

#Problem
146146. LRU Cache
158158. Read N Characters Given Read4 II Call Multiple Times
208208. Implement Trie Prefix Tree
211211. Design Add and Search Words Data Structure
215215. Kth Largest Element in an Array
295295. Find Median from Data Stream
303303. Range Sum Query Immutable
304304. Range Sum Query 2D Immutable
307307. Range Sum Query Mutable
308308. Range Sum Query 2D Mutable
315315. Count of Smaller Numbers After Self
348348. Design Tic-Tac-Toe
359359. Logger Rate Limiter
380380. Insert Delete GetRandom O(1)
384384. Shuffle an Array
642642. Design Search Autocomplete System
731731. My Calendar II
873873. Guess the Word
887887. Minimum Cost to Hire K Workers
879879. Maximize Distance to Closest Person
931931. Maximum Frequency Stack
10141014. K Closest Points to Origin
12491249. Snapshot Array
21392139. Detect Squares
21612161. Stock Price Fluctuation
22002200. Stamping the Grid

Concurrency

#Problem
11871187. Print FooBar Alternately
12031203. Print in Order
12091209. Design Bounded Blocking Queue

JavaScript

#Problem
28092809. Create Hello World Function

🔵 UVA Online Judge

245 solutions in C++.

Graph

200, 247, 294, 336, 383, 406, 524, 532, 583-2, 627, 686, 924, 1148, 1148-1, 1160, 1174, 1234, 10004, 10009, 10009-2, 10034, 10042, 10147, 10200, 10305, 10369, 10397, 10397-2, 10462, 10490, 10592, 10653, 10699, 10789, 11060, 11094, 11504, 11631, 11686, 11709, 11730, 11770, 11838, 11960

Dynamic Programming

111, 147, 231, 357, 481, 497, 562, 562-2, 624, 624-2, 674, 10066, 10100, 10130, 10130-1, 10130-2(bool), 10192, 10364, 10405, 10664, 10664-2, 10721, 10759, 11088, 11137, 11151, 12030, 12455

Math & Number Theory

583, 10104, 10179, 10299, 10780, 11064, 11466, 11889

Greedy

191, 195, 487, 657, 729, 10065, 10078, 10226, 10252, 10336, 10344, 10344-2, 10474, 10556, 10763, 10776, 10946, 11057, 11059, 11343, 11364, 11462, 11462-2, 11462-3, 11462-4, 11612, 11626, 11783, 12614, 12700

Backtracking

146, 195-2, 1079, 10098, 10344-3

Geometry

10525

Sorting & Searching

10611, 11876

Simulation & Ad Hoc

136, 167, 256, 260, 264, 264-2, 324, 350, 352, 369, 374, 382, 417, 441, 444, 445, 459, 469, 484, 490, 492, 495, 514, 541, 572, 574, 574-2nd, 574-3rd, 579, 621, 623, 673, 677, 696, 713, 727, 750, 782, 784, 785, 785-2, 871, 1056, 1056-2, 1112, 1124, 10017, 10048, 10093, 10099, 10110, 10127, 10189, 10190, 10212, 10223, 10263, 10279, 10282, 10282-2, 10295, 10300, 10300-2, 10324, 10334, 10347, 10370, 10394, 10420, 10432, 10452, 10469, 10494, 10494-2, 10515, 10533, 10550, 10579, 10583, 10608, 10673-1, 10673-2, 10685, 10703, 10773, 10783, 10922, 10935, 11029, 11044, 11085, 11220, 11223, 11244, 11344, 11349, 11470-2, 11498, 11526, 11541, 11561, 11648, 11723, 11728, 11879, 11942, 11942-2, 11953, 11960-2, 11965, 11965-2, 12114, 12149, 12157, 12243, 12279, 12289, 12342, 12372, 12416, 12555, 12555-2, 12577, 12578, 12592, 12608, 12643, 12646


🟢 LightOJ

172 solutions in C++.

Graph

1003, 1009, 1026, 1034, 1046, 1063, 1066, 1101, 1111, 1141, 1168, 1174, 1175, 1185, 1210, 1238, 1257, 1263, 1291, 1300, 1300-2, 1337, 1348, 1348 [with comments], 1417

Dynamic Programming

1004, 1006, 1011, 1011-2, 1013, 1017, 1021, 1025, 1030, 1032, 1033, 1037, 1038, 1044, 1047, 1047 (2), 1051, 1051-2, 1057, 1064, 1068, 1110, 1110-2, 1119, 1140, 1157, 1157 (modified), 1157-2, 1157-3, 1158, 1159, 1169, 1191, 1217, 1231, 1283

Math & Number Theory

1005, 1007, 1024, 1027, 1028, 1048, 1054, 1065, 1067, 1076, 1077, 1083, 1085, 1089, 1098, 1112-BIT, 1114, 1129, 1135, 1148, 1163, 1166, 1183, 1183-2nd, 1187, 1187 (2), 1188, 1189, 1197, 1207, 1213, 1215, 1220, 1234, 1259, 1389, 1425

Data Structures

1083 [divide n conquer], 1224, 1339, 1424

Backtracking

1042, 1042-2

String

1039, 1039-2, 1255, 1258

Sorting & Searching

1127

Simulation & Ad Hoc

1008, 1010, 1012, 1014, 1016, 1020, 1022, 1023, 1035, 1043, 1045, 1049, 1049-1, 1053, 1062, 1069, 1072, 1078, 1080, 1082, 1087, 1088, 1090, 1093, 1094, 1096, 1107, 1109, 1112, 1113, 1116, 1122, 1131, 1133, 1136, 1138, 1164, 1164-2nd, 1182, 1186, 1192, 1198, 1202, 1212, 1214, 1225, 1227, 1235, 1236, 1241, 1247, 1249, 1253, 1266, 1282, 1294, 1307, 1338, 1354, 1387, 1393, 1414, 1882


🟠 Codeforces

212 contests solved.

By Category:

Dynamic Programming

79C, 189A, 271D, 372B, 401D, 456C, 467C, 518D, 550C, 604C, 608C, 1363F, 1366C, 1382D, 1384B1, 1398D

Graph

230B, 274B, 275D, 369C, 377A, 378C, 385C, 412D, 427C, 475B, 584D, 588B, 688C, 1362D, 1363E, 1364D, 1366D, 1370C, 1372B, 1388C

Math & Number Theory

271B, 340A, 389A, 472A, 483A, 583C, 742C, 798C

Data Structures

1362B, 1368D, 1370B, 1375D

Greedy

375A, 376C, 389E, 413C

Sorting & Searching

1358D, 1366E

Contests:

3, 23, 31, 41, 52, 59, 61, 69, 71, 79, 95, 110, 112, 115, 116, 136, 189, 208, 217, 218, 230, 231, 236, 246, 253, 258, 260, 263, 265, 266, 268, 270, 271, 272, 274, 275, 276, 278, 281, 282, 284, 291, 294, 295, 296, 300, 302, 312, 313, 315, 318, 319, 330, 332, 334, 339, 340, 344, 347, 349, 350, 353, 355, 357, 358, 361, 362, 363, 366, 368, 369, 372, 375, 376, 377, 378, 379, 381, 382, 384, 385, 387, 389, 400, 401, 402, 404, 405, 412, 413, 416, 421, 427, 430, 432, 439, 441, 446, 450, 451, 452, 456, 459, 460, 462, 463, 465, 466, 467, 469, 472, 474, 475, 476, 478, 479, 483, 485, 486, 488, 489, 490, 492, 493, 494, 497, 499, 500, 507, 509, 513, 514, 516, 518, 519, 525, 526, 538, 550, 551, 555, 557, 567, 583, 584, 586, 588, 591, 593, 595, 604, 608, 610, 611, 614, 618, 624, 629, 631, 664, 670, 688, 701, 734, 735, 740, 742, 743, 747, 749, 752, 764, 765, 766, 768, 796, 798, 1118, 1140, 1162, 1341, 1342, 1343, 1345, 1348, 1352, 1353, 1354, 1358, 1359, 1360, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1380, 1382, 1384, 1388, 1389, 1391, 1398

Gym:100513


🔴 SPOJ

20 solutions in C++.

Data Structures

#ProblemLink
1043GSS11043. GSS1.cpp
1043GSS1 (2nd)1043. GSS1-2nd.cpp
1716GSS31716. GSS3.cpp
3267DQUERY3267. DQUERY.cpp
3693KGSS3693. KGSS.cpp
6256INVCNT6256. INVCNT.cpp
8002Horrible8002. Horrible.cpp
8060AMR10F8060 AMR10F.cpp

Dynamic Programming

#ProblemLink
423Assignments423. Assignments.cpp

Graph

#ProblemLink
913QTREE2913. QTREE2.cpp
14920MST114920 MST1.cpp

Math & Number Theory

#ProblemLink
78Marbles78. Marbles.cpp
4300Rectangles4300 Rectangles.cpp
DIVSUMSPOJ DIVSUM.cpp

Greedy

#ProblemLink
3921BYTESE23921 BYTESE2.cpp

Sorting & Searching

#ProblemLink
1837Pie1837 Pie.cpp

Simulation & Ad Hoc

#ProblemLink
2123Candy I2123. Candy I.cpp
HELLOKITSPOJ HELLOKIT.cpp
VONNYSPOJ VONNY.cpp
VONNY (2nd)SPOJ VONNY-2.cpp

🟣 TopCoder

55 problems solved in C++.

Dynamic Programming

EmoticonsDiv2, FoxAndMp3Easy, ListeningIn, NumberofFiboCalls, NumberofFiboCalls-1, PalindromicSubstringsDiv2, PlatformJumper, ShorterSuperSum, SumsOfPerfectPowers, ThePalindrome

Greedy

BinPacking, BinPackingEasy, Drbalance, SplitIntoPairs

String

DoubleLetter, EllysNewNickname, ErasingCharacters, FoxAndWord, InterestingNumber, SpamChecker, TaroString, TypingDistance

Math & Geometry

AlternateColors, BearPaints, BishopMove, BoundingBox, CandyMaking, LotteryTicket, RectangleCoveringEasy

Simulation & Ad Hoc

AlienAndPassword, BagsQuiz, CatsOnTheLineDiv2, Cdgame, DerivativeSequence, DistanceBetweenStrings, Egalitarianism3Easy, FibonacciDiv2, Haar1D, LeftAndRightHandedDiv2, LittleElephantAndBooks, LittleElephantAndDouble, LittleElephantAndString, MagicalStringDiv2, MicroStrings, MiddleCode, MysticAndCandiesEasy, OneDimensionalRobotEasy, PackingBallsDiv2, RobotHerbDiv2, SRMCards, SilverbachConjecture, TaroGrid, TypoCoderDiv2, WinterAndCandies, WinterAndMandarins

About

💻 📊 Competitive Programming environment and personal solution archive of different online problems.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages