Skip to content

Pure C solution for LeetCode

Notifications You must be signed in to change notification settings

lennylxx/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Pure C solution for LeetCode

This project aims at solving LeetCode algorithm problems with pure C Language using as little library functions as I can, which means except memory management functions and few string functions I will implement everything I need such as trees, stacks, queues and hash tables.

Parts of the problems don't provide C interface for solution, so I accomplished them with C++ Language.

Compile C files using command:

gcc -std=c99 -Wall src/foo.c -o foo 

Compile C++ files using command:

g++ -std=c++11 -Wall src/bar.cpp -o bar 

OR

You can build all the files using make (Use MinGW GCC and GNU Make on Windows).

The means that you need to have a LeetCode Premium Subscription.

ProblemSolution
315Count of Smaller Numbers After Self
314Binary Tree Vertical Order Traversal
313Super Ugly NumberC
312Burst Balloons
311Sparse Matrix Multiplication
310Minimum Height Trees
309Best Time to Buy and Sell Stock with Cooldown
308Range Sum Query 2D - Mutable
307Range Sum Query - Mutable
306Additive Number
305Number of Islands II
304Range Sum Query 2D - Immutable
303Range Sum Query - Immutable
302Smallest Rectangle Enclosing Black Pixels
301Remove Invalid Parentheses
300Longest Increasing SubsequenceC
299Bulls and CowsC
298Binary Tree Longest Consecutive Sequence
297Serialize and Deserialize Binary TreeC++
296Best Meeting Point
295Find Median from Data StreamC
294Flip Game II
293Flip Game
292Nim GameC
291Word Pattern II
290Word PatternC++
289Game of LifeC
288Unique Word Abbreviation
287Find the Duplicate Number
286Walls and Gates
285Inorder Successor in BST
284Peeking IteratorC++
283Move ZeroesC
282Expression Add Operators
281Zigzag Iterator
280Wiggle Sort
279Perfect SquaresC
278First Bad VersionC
277Find the Celebrity
276Paint Fence
275H-Index IIC
274H-IndexC
273Integer to English Words
272Closest Binary Search Tree Value II
271Encode and Decode Strings
270Closest Binary Search Tree Value
269Alien Dictionary
268Missing NumberC
267Palindrome Permutation II
266Palindrome Permutation
265Paint House II
264Ugly Number IIC
263Ugly NumberC
261Graph Valid Tree
260Single Number IIIC
2593Sum Smaller
258Add DigitsC
257Binary Tree PathsC++
256Paint House
255Verify Preorder Sequence in Binary Search Tree
254Factor Combinations
253Meeting Rooms II
252Meeting Rooms
251Flatten 2D Vector
250Count Univalue Subtrees
249Group Shifted Strings
248Strobogrammatic Number III
247Strobogrammatic Number II
246Strobogrammatic Number
245Shortest Word Distance III
244Shortest Word Distance II
243Shortest Word Distance
242Valid AnagramC
241Different Ways to Add ParenthesesC++
240Search a 2D Matrix IIC
239Sliding Window Maximum
238Product of Array Except SelfC
237Delete Node in a Linked ListC
236Lowest Common Ancestor of a Binary TreeC++
235Lowest Common Ancestor of a Binary Search TreeC
234Palindrome Linked ListC
233Number of Digit OneC
232Implement Queue using StacksC
231Power of TwoC
230Kth Smallest Element in a BSTC
229Majority Element II
228Summary RangesC
227Basic Calculator II
226Invert Binary TreeC
225Implement Stack using QueuesC
224Basic CalculatorC
223Rectangle AreaC
222Count Complete Tree NodesC
221Maximal SquareC++
220Contains Duplicate III
219Contains Duplicate IIC
218The Skyline Problem
217Contains DuplicateC
216Combination Sum IIIC++
215Kth Largest Element in an ArrayC
214Shortest Palindrome
213House Robber IIC
212Word Search IIC
211Add and Search Word - Data structure designC
210Course Schedule II
209Minimum Size Subarray SumC
208Implement Trie (Prefix Tree)C
207Course Schedule
206Reverse Linked ListC
205Isomorphic StringsC
204Count PrimesC
203Remove Linked List ElementsC
202Happy NumberC
201Bitwise AND of Numbers RangeC
200Number of IslandsC
199Binary Tree Right Side ViewC
198House RobberC
191Number of 1 BitsC
190Reverse BitsC
189Rotate ArrayC
188Best Time to Buy and Sell Stock IV
187Repeated DNA Sequences
186Reverse Words in a String II
179Largest NumberC
174Dungeon Game
173Binary Search Tree IteratorC++
172Factorial Trailing ZeroesC
171Excel Sheet Column NumberC
170Two Sum III - Data structure design
169Majority ElementC
168Excel Sheet Column TitleC
167Two Sum II - Input array is sorted
166Fraction to Recurring Decimal
165Compare Version NumbersC
164Maximum GapC
163Missing Ranges
162Find Peak ElementC
161One Edit Distance
160Intersection of Two Linked ListsC
159Longest Substring with At Most Two Distinct Characters
158Read N Characters Given Read4 II - Call multiple times
157Read N Characters Given Read4
156Binary Tree Upside Down
155Min StackC
154Find Minimum in Rotated Sorted Array IIC
153Find Minimum in Rotated Sorted ArrayC
152Maximum Product SubarrayC
151Reverse Words in a StringC
150Evaluate Reverse Polish NotationC
149Max Points on a Line
148Sort ListC
147Insertion Sort ListC
146LRU CacheC
145Binary Tree Postorder TraversalC
144Binary Tree Preorder TraversalC++
143Reorder ListC
142Linked List Cycle IIC
141Linked List CycleC
140Word Break II
139Word BreakC++
138Copy List with Random PointerC
137Single Number II
136Single NumberC
135Candy
134Gas StationC
133Clone GraphC++
132Palindrome Partitioning IIC++
131Palindrome PartitioningC++
130Surrounded Regions
129Sum Root to Leaf NumbersC
128Longest Consecutive SequenceC
127Word LadderC++
126Word Ladder II
125Valid PalindromeC
124Binary Tree Maximum Path Sum
123Best Time to Buy and Sell Stock III
122Best Time to Buy and Sell Stock IIC
121Best Time to Buy and Sell StockC
120TriangleC
119Pascal's Triangle IIC
118Pascal's TriangleC
117Populating Next Right Pointers in Each Node II
116Populating Next Right Pointers in Each NodeC
115Distinct SubsequencesC
114Flatten Binary Tree to Linked ListC
113Path Sum IIC++
112Path SumC
111Minimum Depth of Binary TreeC
110Balanced Binary TreeC
109Convert Sorted List to Binary Search TreeC++
108Convert Sorted Array to Binary Search TreeC
107Binary Tree Level Order Traversal IIC++
106Construct Binary Tree from Inorder and Postorder TraversalC
105Construct Binary Tree from Preorder and Inorder TraversalC
104Maximum Depth of Binary TreeC
103Binary Tree Zigzag Level Order TraversalC++
102Binary Tree Level Order TraversalC
101Symmetric TreeC
100Same TreeC
99Recover Binary Search Tree
98Validate Binary Search TreeC
97Interleaving String
96Unique Binary Search TreesC
95Unique Binary Search Trees IIC++
94Binary Tree Inorder TraversalC
93Restore IP AddressesC++
92Reverse Linked List IIC
91Decode WaysC
90Subsets IIC++
89Gray CodeC
88Merge Sorted ArrayC
87Scramble String
86Partition ListC
85Maximal Rectangle
84Largest Rectangle in Histogram
83Remove Duplicates from Sorted ListC
82Remove Duplicates from Sorted List IIC
81Search in Rotated Sorted Array IIC
80Remove Duplicates from Sorted Array IIC
79Word SearchC
78SubsetsC++
77CombinationsC++
76Minimum Window Substring
75Sort ColorsC
74Search a 2D MatrixC
73Set Matrix ZeroesC
72Edit DistanceC
71Simplify Path
70Climbing StairsC
69Sqrt(x)C
68Text Justification
67Add BinaryC
66Plus OneC
65Valid NumberC
64Minimum Path SumC
63Unique Paths IIC
62Unique PathsC
61Rotate ListC
60Permutation SequenceC++
59Spiral Matrix IIC
58Length of Last WordC
57Insert Interval
56Merge Intervals
55Jump GameC
54Spiral MatrixC
53Maximum SubarrayC
52N-Queens IIC
51N-QueensC++
50Pow(x, n)C
49AnagramsC++
48Rotate ImageC
47Permutations II
46PermutationsC
45Jump Game II
44Wildcard MatchingC
43Multiply StringsC
42Trapping Rain Water
41First Missing PositiveC
40Combination Sum IIC++
39Combination SumC++
38Count and SayC
37Sudoku SolverC++
36Valid SudokuC
35Search Insert PositionC
34Search for a RangeC++
33Search in Rotated Sorted ArrayC
32Longest Valid Parentheses
31Next PermutationC
30Substring with Concatenation of All Words
29Divide Two Integers
28Implement strStr()C
27Remove ElementC
26Remove Duplicates from Sorted ArrayC
25Reverse Nodes in k-GroupC
24Swap Nodes in PairsC
23Merge k Sorted ListsC
22Generate ParenthesesC++
21Merge Two Sorted ListsC
20Valid ParenthesesC
19Remove Nth Node From End of ListC
184Sum
17Letter Combinations of a Phone NumberC++
163Sum Closest
153SumC++
14Longest Common PrefixC
13Roman to IntegerC
12Integer to RomanC
11Container With Most Water
10Regular Expression Matching
9Palindrome NumberC
8String to Integer (atoi)C
7Reverse IntegerC
6ZigZag ConversionC
5Longest Palindromic SubstringC++
4Median of Two Sorted Arrays
3Longest Substring Without Repeating Characters
2Add Two NumbersC
1Two SumC

About

Pure C solution for LeetCode

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
close