Skip to content

palytoxin/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.

Problem Solution
300 Longest Increasing Subsequence C
299 Bulls and Cows C
298 Binary Tree Longest Consecutive Sequence
297 Serialize and Deserialize Binary Tree C++
296 Best Meeting Point
295 Find Median from Data Stream C
294 Flip Game II
293 Flip Game
292 Nim Game C
291 Word Pattern II
290 Word Pattern C++
289 Game of Life C
288 Unique Word Abbreviation
287 Find the Duplicate Number
286 Walls and Gates
285 Inorder Successor in BST
284 Peeking Iterator C++
283 Move Zeroes C
282 Expression Add Operators
281 Zigzag Iterator
280 Wiggle Sort
279 Perfect Squares C
278 First Bad Version C
277 Find the Celebrity
276 Paint Fence
275 H-Index II C
274 H-Index C
273 Integer to English Words
272 Closest Binary Search Tree Value II
271 Encode and Decode Strings
270 Closest Binary Search Tree Value
269 Alien Dictionary
268 Missing Number C
267 Palindrome Permutation II
266 Palindrome Permutation
265 Paint House II
264 Ugly Number II C
263 Ugly Number C
261 Graph Valid Tree
260 Single Number III C
259 3Sum Smaller
258 Add Digits C
257 Binary Tree Paths C++
256 Paint House
255 Verify Preorder Sequence in Binary Search Tree
254 Factor Combinations
253 Meeting Rooms II
252 Meeting Rooms
251 Flatten 2D Vector
250 Count Univalue Subtrees
249 Group Shifted Strings
248 Strobogrammatic Number III
247 Strobogrammatic Number II
246 Strobogrammatic Number
245 Shortest Word Distance III
244 Shortest Word Distance II
243 Shortest Word Distance
242 Valid Anagram C
241 Different Ways to Add Parentheses C++
240 Search a 2D Matrix II C
239 Sliding Window Maximum
238 Product of Array Except Self C
237 Delete Node in a Linked List C
236 Lowest Common Ancestor of a Binary Tree C++
235 Lowest Common Ancestor of a Binary Search Tree C
234 Palindrome Linked List C
233 Number of Digit One C
232 Implement Queue using Stacks C
231 Power of Two C
230 Kth Smallest Element in a BST C
229 Majority Element II
228 Summary Ranges C
227 Basic Calculator II
226 Invert Binary Tree C
225 Implement Stack using Queues C
224 Basic Calculator C
223 Rectangle Area C
222 Count Complete Tree Nodes C
221 Maximal Square C++
220 Contains Duplicate III
219 Contains Duplicate II C
218 The Skyline Problem
217 Contains Duplicate C
216 Combination Sum III C++
215 Kth Largest Element in an Array C
214 Shortest Palindrome
213 House Robber II C
212 Word Search II C
211 Add and Search Word - Data structure design C
210 Course Schedule II
209 Minimum Size Subarray Sum C
208 Implement Trie (Prefix Tree) C
207 Course Schedule
206 Reverse Linked List C
205 Isomorphic Strings C
204 Count Primes C
203 Remove Linked List Elements C
202 Happy Number C
201 Bitwise AND of Numbers Range C
200 Number of Islands C
199 Binary Tree Right Side View C
198 House Robber C
191 Number of 1 Bits C
190 Reverse Bits C
189 Rotate Array C
188 Best Time to Buy and Sell Stock IV
187 Repeated DNA Sequences
186 Reverse Words in a String II
179 Largest Number C
174 Dungeon Game
173 Binary Search Tree Iterator C++
172 Factorial Trailing Zeroes C
171 Excel Sheet Column Number C
170 Two Sum III - Data structure design
169 Majority Element C
168 Excel Sheet Column Title C
167 Two Sum II - Input array is sorted
166 Fraction to Recurring Decimal
165 Compare Version Numbers C
164 Maximum Gap C
163 Missing Ranges
162 Find Peak Element C
161 One Edit Distance
160 Intersection of Two Linked Lists C
159 Longest Substring with At Most Two Distinct Characters
158 Read N Characters Given Read4 II - Call multiple times
157 Read N Characters Given Read4
156 Binary Tree Upside Down
155 Min Stack C
154 Find Minimum in Rotated Sorted Array II C
153 Find Minimum in Rotated Sorted Array C
152 Maximum Product Subarray C
151 Reverse Words in a String C
150 Evaluate Reverse Polish Notation C
149 Max Points on a Line
148 Sort List C
147 Insertion Sort List C
146 LRU Cache C
145 Binary Tree Postorder Traversal C
144 Binary Tree Preorder Traversal C++
143 Reorder List C
142 Linked List Cycle II C
141 Linked List Cycle C
140 Word Break II
139 Word Break C++
138 Copy List with Random Pointer C
137 Single Number II
136 Single Number C
135 Candy
134 Gas Station C
133 Clone Graph C++
132 Palindrome Partitioning II C++
131 Palindrome Partitioning C++
130 Surrounded Regions
129 Sum Root to Leaf Numbers C
128 Longest Consecutive Sequence C
127 Word Ladder C++
126 Word Ladder II
125 Valid Palindrome C
124 Binary Tree Maximum Path Sum
123 Best Time to Buy and Sell Stock III
122 Best Time to Buy and Sell Stock II C
121 Best Time to Buy and Sell Stock C
120 Triangle C
119 Pascal's Triangle II C
118 Pascal's Triangle C
117 Populating Next Right Pointers in Each Node II
116 Populating Next Right Pointers in Each Node C
115 Distinct Subsequences C
114 Flatten Binary Tree to Linked List C
113 Path Sum II C++
112 Path Sum C
111 Minimum Depth of Binary Tree C
110 Balanced Binary Tree C
109 Convert Sorted List to Binary Search Tree C++
108 Convert Sorted Array to Binary Search Tree C
107 Binary Tree Level Order Traversal II C++
106 Construct Binary Tree from Inorder and Postorder Traversal C
105 Construct Binary Tree from Preorder and Inorder Traversal C
104 Maximum Depth of Binary Tree C
103 Binary Tree Zigzag Level Order Traversal C++
102 Binary Tree Level Order Traversal C
101 Symmetric Tree C
100 Same Tree C
99 Recover Binary Search Tree
98 Validate Binary Search Tree C
97 Interleaving String
96 Unique Binary Search Trees C
95 Unique Binary Search Trees II C++
94 Binary Tree Inorder Traversal C
93 Restore IP Addresses C++
92 Reverse Linked List II C
91 Decode Ways C
90 Subsets II C++
89 Gray Code C
88 Merge Sorted Array C
87 Scramble String
86 Partition List C
85 Maximal Rectangle
84 Largest Rectangle in Histogram
83 Remove Duplicates from Sorted List C
82 Remove Duplicates from Sorted List II C
81 Search in Rotated Sorted Array II C
80 Remove Duplicates from Sorted Array II C
79 Word Search C
78 Subsets C++
77 Combinations C++
76 Minimum Window Substring
75 Sort Colors C
74 Search a 2D Matrix C
73 Set Matrix Zeroes C
72 Edit Distance C
71 Simplify Path
70 Climbing Stairs C
69 Sqrt(x) C
68 Text Justification
67 Add Binary C
66 Plus One C
65 Valid Number C
64 Minimum Path Sum C
63 Unique Paths II C
62 Unique Paths C
61 Rotate List C
60 Permutation Sequence C++
59 Spiral Matrix II C
58 Length of Last Word C
57 Insert Interval
56 Merge Intervals
55 Jump Game C
54 Spiral Matrix C
53 Maximum Subarray C
52 N-Queens II C
51 N-Queens C++
50 Pow(x, n) C
49 Anagrams C++
48 Rotate Image C
47 Permutations II
46 Permutations C
45 Jump Game II
44 Wildcard Matching C
43 Multiply Strings C
42 Trapping Rain Water
41 First Missing Positive C
40 Combination Sum II C++
39 Combination Sum C++
38 Count and Say C
37 Sudoku Solver C++
36 Valid Sudoku C
35 Search Insert Position C
34 Search for a Range C++
33 Search in Rotated Sorted Array C
32 Longest Valid Parentheses
31 Next Permutation C
30 Substring with Concatenation of All Words
29 Divide Two Integers
28 Implement strStr() C
27 Remove Element C
26 Remove Duplicates from Sorted Array C
25 Reverse Nodes in k-Group C
24 Swap Nodes in Pairs C
23 Merge k Sorted Lists C
22 Generate Parentheses C++
21 Merge Two Sorted Lists C
20 Valid Parentheses C
19 Remove Nth Node From End of List C
18 4Sum
17 Letter Combinations of a Phone Number C++
16 3Sum Closest
15 3Sum C++
14 Longest Common Prefix C
13 Roman to Integer C
12 Integer to Roman C
11 Container With Most Water
10 Regular Expression Matching
9 Palindrome Number C
8 String to Integer (atoi) C
7 Reverse Integer C
6 ZigZag Conversion C
5 Longest Palindromic Substring C++
4 Median of Two Sorted Arrays
3 Longest Substring Without Repeating Characters
2 Add Two Numbers C
1 Two Sum C

About

Pure C solution for LeetCode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 87.4%
  • C++ 12.5%
  • Makefile 0.1%