Ubuntu | MacOS | Win2019 |
---|---|---|
The repo is about transitioning from Python to C family programming. It implements algorithms with C++(Cmake), C#(dotnet), Python(pip) and Javascript(node), and test them with gtest, Xunits, pytest and mocha respectively. To ensure the code quality, it deploys testings via github actions.
algoTest
├── cpp [C++]
│ └── example (Leetcode c++ questions)
│ ├── build (from configure.sh)
│ ├── lib (google tests placeholder)
│ ├── src (solutions)
│ └── tst (test scripts)
├── cs [C#]
│ └── sample (Leetcode c# questions)
│ ├── Sample (solutions)
│ └── Sample.Tests (test scripts)
├── cu [cuda]
├── py [Python3]
│ ├── solns (solutions)
│ └── tests (test scripts)
├── js [NodeJS]
├── sh [Shell]
└── sql [SQL]
- For C++ questions, change directory to
cpp/example
, and then run
./init.sh questionName # to initiate a template
./configure.sh # for cmake and debug
./del.sh questionName # to delete the question
- Similarily for C#, change directory to
cs/sample
,
./init.sh questionName # to initiate a template
./del.sh questionName # to delete the question
dotnet build
dotnet run
- Similarily for Python3, change directory to
py
,
./init.sh questionName # to initiate a template
./del.sh questionName # to delete the question
pytest
- To operate on same question with all languages,
./initAll.sh questionName
./delAll.sh questionName
: Solution | ✔️ : Test | Click on Icon to read the code.
Click to expand!
Tasks | C++ | C# | Python | Topics |
---|---|---|---|---|
Karatsuba Multiplication | ✔️ | Divide and Conquer | ||
Bubble Sort | ✔️ | ✔️ | ✔️ | Sorting Algorithm |
Merge Sort | ✔️ | ✔️ | ✔️ | Sorting Algorithm, Divide and Conquer |
Count Inversions | ✔️ | ✔️ | Divide and Conquer | |
Quick Sort | ✔️ | ✔️ | Sorting Algorithm, Divide and Conquer | |
N-th Order Statistics | ✔️ | Divide and Conquer, Randomized Algorithm | ||
Minimum Cuts | ✔️ | ✔️ | Graph, Randomized Algorithm | |
Breadth First Search | ✔️ | ✔️ | Graph, BFS, Queue | |
Shortest Paths | ✔️ | Graph, BFS | ||
Undirected Connectivity | ✔️ | Undirected Graph, BFS | ||
Depth First Search | ✔️ | Graph, DFS | ||
Topological Sort | ✔️ | Directed Acyclic Graph, DFS | ||
Strongly Connected Components | ✔️ | Directed Graph, DFS | ||
Dijkstra Algorithm | ✔️ | Directed Graph, Heap | ||
Heap | Array, Heap | |||
Selection Sort | Sorting Algorithm | |||
Heap Sort | Sorting Algorithm, Heap | |||
Median Maintenance | ✔️ | Heap | ||
Red Black Trees | Binary Search Tree | |||
Hash Table | Hashmap | |||
Bloom Filters | Bloom Filters | |||
Union Find | Union Find | |||
Two Sums | Hashmap |
Click to expand!
Tasks | C++ | C# | Python | Topics | |
---|---|---|---|---|---|
ListNode | ✔️ | ✔️ | Linked List | ||
TreeNode | ✔️ | ✔️ | ✔️ | Tree | |
Graph | ✔️ | ✔️ | ✔️ | Graph (Directed, Undirected) | |
1* | Two Sum | ✔️ | ✔️ | ✔️ | Array, Hash map |
2 | Add Two Numbers | ✔️ | ✔️ | ✔️ | Linked List |
3* | Longest Substring Without Repeating Characters | ✔️ | ✔️ | ✔️ | String, Set, Two Pointers, Sliding Window |
5* | Longest Palindromic Substring | ✔️ | ✔️ | String | |
7 | Reverse Integer | ✔️ | ✔️ | ✔️ | |
9 | Palindrome Number | ✔️ | ✔️ | ✔️ | |
11* | Container With Most Water | ✔️ | ✔️ | ✔️ | Array, Pointer |
13 | Roman to Integer | ✔️ | ✔️ | ✔️ | |
15* | 3Sum | ✔️ | Array, Binary Search | ||
17 | Letter Combinations of a Phone Number | DFS | |||
19* | Remove Nth Node from End of List | ✔️ | Linked List | ||
20* | Valid Parentheses | ✔️ | ✔️ | ✔️ | Stack, Hashmap, Set |
21* | Merge Two Sorted Lists | ✔️ | ✔️ | ✔️ | Linked List |
23* | Merge K Sorted Lists | ✔️ | Linked List, Heap | ||
26 | Remove Duplicates from Sorted Array | ✔️ | ✔️ | ✔️ | Pointers, Inplace Operation |
27 | Remove Element | ✔️ | ✔️ | ✔️ | Pointers, Inplace Operation |
31 | Next Permutation | Pointers | |||
33* | Search in Rotated Sorted Array | ✔️ | ✔️ | ✔️ | Array |
34 | Find First and Last Position of Element in Sorted Array | Array, Binary Search | |||
35 | Search Insert Position | ✔️ | Two Pointers | ||
36 | Valid Sudoku | ✔️ | Set | ||
37 | Sudoku Solver | ✔️ | Set | ||
39* | Combination Sum | ✔️ | Recursive, DFS, Backtracking | ||
40 | Combination Sum II | DFS | |||
42 | Trapping Rain Water | List | |||
46 | Permutations | ✔️ | Recursive, DFS, Backtracking | ||
47 | Permutations II | ✔️ | Recursive, DFS, Backtracking | ||
48* | Rotate Image | ✔️ | ✔️ | Matrix | |
49* | Group Anagrams | ✔️ | String, Hashmap | ||
53* | Maximum Subarray | ✔️ | ✔️ | ✔️ | Array |
54* | Spiral Matrix | ✔️ | Matrix | ||
55* | Jump Game | ✔️ | Dynamic Programming, Greedy | ||
56* | Merge Intervals | ✔️ | Interval | ||
57* | Insert Interval | ✔️ | Interval | ||
58 | Length of Last Word | String | |||
62* | Unique Paths | ✔️ | Dynamic Programming | ||
63 | Unique Paths II | Dynamic Programming | |||
64 | Minimum Path Sum | ✔️ | Dynamic Programming, DFS | ||
66 | Plus One | ✔️ | ✔️ | ✔️ | |
68 | Text Justification | String | |||
69 | Sqrtx | ✔️ | ✔️ | ✔️ | Binary Search |
70* | Climbing Stairs | ✔️ | ✔️ | ✔️ | Dynamic Programming |
73* | Set Matrix Zeros | ✔️ | Matrix | ||
74 | Search a 2D Matrix | Binary Search, Matrix | |||
76* | Minimum Window Substring | ✔️ | String | ||
77 | Combinations | ✔️ | DFS | ||
78 | Subsets | ✔️ | DFS | ||
79* | Word Search | ✔️ | Matrix | ||
82 | Remove Duplicates from Sorted Array 2 | ✔️ | Linked List | ||
90 | Subsets II | ✔️ | DFS, Set, Sorting | ||
91* | Decode Ways | ✔️ | DFS, Recursive, Dynamic Programming | ||
94 | Binary Tree Level Order Traversal | ✔️ | ✔️ | Binary Tree, Inorder Traversal | |
98* | Validate Binary Search Tree | ✔️ | Binary Search Tree, DFS | ||
100* | Same Tree | ✔️ | ✔️ | ✔️ | Tree |
101 | Symmetric Tree | Binary Tree | |||
102* | Binary Tree Level Order Traversal | ✔️ | Binary Search Tree, DFS | ||
103 | Binary Tree Zigzag Level Order Traversal | Binary Tree, DFS | |||
104* | Maximum Depth of Binary Tree | ✔️ | Binary Tree, Recursion, DFS | ||
105* | Construct Binary Tree from Preorder and Inorder Traversal | ✔️ | Binary Tree, DFS | ||
107 | Binary Tree Level Order Traversal II | Binary Tree, DFS | |||
111 | Minimum Depth of Binary Tree | Binary Tree | |||
112 | Path Sum | ✔️ | ✔️ | ✔️ | Tree |
118 | Pascal's Triangle | List | |||
119 | Pascal's Triangle II | List | |||
121* | Best Time to Buy and Sell Stock | ✔️ | ✔️ | ✔️ | Array |
122 | Best Time to Buy and Sell Stock II | Array | |||
124* | Binary Tree Maximum Path Sum | ✔️ | Binary Tree | ||
125* | Valid Palindrome | ✔️ | String, Two Pointers | ||
128* | Longest Consecutive Sequence | ✔️ | Set, Graph | ||
129 | Sum Root to Leaf Numbers | Binary Tree | |||
133* | Clone Graph | ✔️ | BFS, Graph | ||
139* | Word Break | ✔️ | Recursive, DFS, Dynamic Programming | ||
141* | Linked List Cycle | ✔️ | Linked List | ||
142 | Linked List Cycle 2 | ✔️ | Linked List | ||
143* | Reorder List | ✔️ | Linked List | ||
144 | Binary Tree Preorder Traversal | ✔️ | ✔️ | Binary Tree, Preorder Traversal | |
145 | Binary Tree Postorder Traversal | ✔️ | ✔️ | Binary Tree, Postorder Traversal | |
148 | Sort List | Linked List, Divide and Conquer | |||
152* | Maximum Product Subarray | ✔️ | ✔️ | ✔️ | Array |
153* | Find Minimum in Rotated Sorted Array | ✔️ | ✔️ | ✔️ | Array |
167 | Two Sum II - Input Array Is Sorted | ✔️ | ✔️ | Binary Search | |
182 | Duplicate Emails | ✔️ | ✔️ | ✔️ | SQL, Sqlite3 |
190* | Reverse Bits | ✔️ | ✔️ | Bitwise Operation | |
191* | Number of 1 Bits | ✔️ | ✔️ | Bitwise Operation | |
193 | Valid Phone Numbers | Shell, Regular Expression | |||
195 | Tenth Line | ✔️ | ✔️ | ✔️ | Shell |
198* | House Robber | ✔️ | Dynamic Programming | ||
200* | Number of Islands | ✔️ | Graph, DFS | ||
203 | Remove Linked List Elements | ✔️ | Linked List | ||
206* | Reverse Linked List | ✔️ | Linked List | ||
207* | Course Schedule | ✔️ | Graph | ||
208* | Implement Trie (Prefix Tree) | ✔️ | Prefix Tree | ||
211* | Design Add and Search Words Data Structure | ✔️ | Prefix Tree | ||
212* | Word Search II | Tree | |||
213* | House Robber 2 | ✔️ | Dynamic Programming | ||
216 | Combination Sum III | DFS | |||
217* | Contains Duplicate | ✔️ | ✔️ | ✔️ | Array, Set |
219 | Contains Duplicate 2 | ✔️ | ✔️ | ✔️ | Hashmap |
226* | Invert Binary Tree | ✔️ | Binary Tree, DFS | ||
230* | Kth Smallest Element in a BST | ✔️ | Binary Search Tree, DFS | ||
235* | Lowest Common Ancestor of a Binary Search Tree | ✔️ | Binary Search Tree | ||
238* | Product of Array Except Self | ✔️ | ✔️ | ✔️ | Array |
242* | Valid Anagram | ✔️ | String, Hashmap | ||
252* | Meeting Rooms | ✔️ | Interval | ||
253* | Meeting Rooms II | ✔️ | Interval | ||
257 | Binary Tree Paths | Binary Tree | |||
261* | Graph Valid Tree | ✔️ | Graph, Tree, DFS | ||
268* | Missing Number | ✔️ | ✔️ | Bitwise Operation | |
269* | Alien Dictionary | ✔️ | Graph, DFS, Topological Sort | ||
271* | Encode and Decode Strings | ✔️ | String | ||
295* | Find Median from Data Stream | ✔️ | Heap | ||
297* | Serialize and Deserialize Binary Tree | ✔️ | Binary Tree, Preorder Traversal | ||
300* | Longest Increasing Subsequence | ✔️ | Recursive, DFS, Dynamic Programming | ||
314 | Binary Tree Vertical Order Traversal | Binary Tree, BFS | |||
322* | Coin Change | ✔️ | Recursive, DFS, Dynamic Programming | ||
323* | Number of Connected Components in an Undirected Graph | ✔️ | DFS, Graph | ||
338* | Counting Bits | ✔️ | Bitwise Operation | ||
347* | Top K Frequent Elements | ✔️ | Heap | ||
359 | Logger Rate Limiter | Hashmap | |||
366 | Find Leaves in Binary Tree | Binary Tree | |||
371* | Sum of Two Integers | ✔️ | ✔️ | Bitwise Operation | |
377 | Combination Sum IV | Dynamic Programming | |||
394 | Decode String | ✔️ | Stack | ||
404 | Sum of Left Leaves | ✔️ | ✔️ | ✔️ | Tree |
417* | Pacific Atlantic Water Flow | ✔️ | Graph, DFS | ||
423 | Reconstruct Original Digits from English | DFS | |||
424* | Longest Repeating Character Replacement | ✔️ | String, Hashmap, Two Pointers | ||
435* | Non-overlapping Intervals | ✔️ | Interval | ||
442 | Find All Duplicates in an Array | ✔️ | ✔️ | ✔️ | Hashmap |
509 | Fibonacci Number | Dynamic Programming | |||
538 | Convert BST to Greater Tree | ✔️ | BST, DFS, Recursive | ||
572* | Subtree of Another Tree | ✔️ | Binary Tree. DFS | ||
589 | N-ary Tree Preorder Traversal | ✔️ | ✔️ | Tree, Preorder Traversal | |
590 | N-ary Tree Postorder Traversal | ✔️ | ✔️ | Tree, Postorder Traversal | |
637 | Average of Levels in Binary Tree | Binary Tree | |||
647* | Palindromic Substrings | ✔️ | ✔️ | String | |
652 | Find Duplicate Subtrees | Binary Tree, DFS, Hashmap | |||
662 | Maximum Width of Binary Tree | Binary Tree | |||
695 | Max Area of Island | ✔️ | Graph, DFS | ||
696 | Count Binary Substrings | List, String | |||
700 | Search in a Binary Search Tree | ✔️ | Binary Search Tree | ||
704 | Binary Search | ✔️ | ✔️ | ✔️ | Binary Search |
814 | Binary Tree Pruning | ✔️ | Binary Tree, DFS | ||
876 | Middle of the Linked List | ✔️ | Linked List | ||
912 | Sort an Array | ✔️ | ✔️ | ✔️ | Sorting Algorithm, Divide and Conquer |
938 | Range Sum of BST | ✔️ | DFS, Binary Search Tree | ||
973 | K Closest Points to Origin | Heap, Sorting | |||
980 | Unique Paths III | Graph, DFS, Backtracking | |||
989 | Add to Array-Form of Integer | ✔️ | ✔️ | ✔️ | |
1009 | Complement of Base 10 Integer | ✔️ | ✔️ | ✔️ | Bitwise Operation |
1023 | Camelcase Matching | String | |||
1056 | Confusing Number | ✔️ | ✔️ | ✔️ | Hashmap, Set |
1089 | Duplicate Zeros | ✔️ | ✔️ | ✔️ | Inplace Operation |
1091 | Shortest Path in Binary Matrix | Graph, Backtracking, BFS | |||
1119 | Remove Vowels from a String | ✔️ | ✔️ | ✔️ | Regular Expression |
1143* | Longest Common Subsequence | ✔️ | Backtracking, Recursive, Dynamic Programming | ||
1146 | Snapshot Array | Hashmap | |||
1277 | Count Square Submatrices with All Ones | Matrix, Dynamic Programming | |||
1288 | Remove Covered Intervals | Interval | |||
1290 | Convert Binary Number in a Linked List to Integer | ✔️ | ✔️ | ✔️ | Linked List |
1293 | Shortest Path in a Grid with Obstacles Elimination | Dynamic Programming, DFS, Graph | |||
1304 | Find N Unique Integers Sum up to Zero | ✔️ | ✔️ | ✔️ | |
1356 | Sort Integers by The Number of 1 Bits | ✔️ | ✔️ | Bitwise Operation | |
1394 | Find Lucky Integer in an Array | ✔️ | ✔️ | ✔️ | Hashmap |
1446 | Consecutive Characters | ✔️ | |||
1464 | Maximum Product of Two Elements in Array | ✔️ | ✔️ | ✔️ | Pointers |
1518 | Water Bottles | ||||
1592 | Rearrange Spaces Between Words | String | |||
1609 | Even Odd Tree | Binary Tree | |||
1805 | Number of Different Integers in a String | ✔️ | ✔️ | ✔️ | Set |
1812 | Determine Color of a Chessboard Square | Hashmap | |||
1836 | Remove Duplicates From an Unsorted Linked List | ✔️ | Linked List | ||
1929 | Concatenation of Array | List | |||
2007 | Find Original Array From Doubled Array | Hashmap | |||
2096 | Step-By-Step Directions From a Binary Tree Node to Another | Hashmap, Graph, Binary Tree |
Click to expand!
Tasks | C++ | C# | Python | Js | Topics |
---|---|---|---|---|---|
Unit Testing | ✔️ | ✔️ | ✔️ | ✔️ | Unit Testing |
Parameterized Unit Testing | ✔️ | ✔️ | ✔️ | Unit Testing | |
Testing with Fixture | ✔️ | ✔️ | Unit Testing |
Click to expand!
Tasks | Language | Topics | |
---|---|---|---|
Height of a Binary Tree | ✔️ | Python | Binary Tree |
Lowest Common Ancestor | ✔️ | Python | Binary Search Tree |
Is This a Binary Search Tree? | ✔️ | Python | Binary Search Tree |
Huffman Decoding | ✔️ | Python | Binary Tree |
Click to expand!
Tasks | Topics | |
---|---|---|
League Table | ✔️ | Python, Counter, OrderedDict, Sorting |
Ice Cream Machine | ✔️ | Python |
Binary Search Tree | ✔️ | Python, NamedTuple, BST |
Merge Names | ✔️ | Python, Set |
Sorted Search | ✔️ | Python, Binary Search |
File Owners | ✔️ | Python |
Song | ✔️ | Python, Linked List |
Train Composition | ✔️ | Python, Deque |
Route Planner | ✔️ | Python, Stack, DFS, Graph |
Two Sum | ✔️ | Python |
Pipeline | ✔️ | Python, Nested Function |
Log Patch | ✔️ | Python, Monkey Patching |
Iris Classifier | ✔️ | Python, Data Science, Sklearn |
Login Table | ✔️ | Python, Data Science, Pandas |
Dog Classification | ✔️ | Python, Data Science, Decision Boundary |
Stock Prices | ✔️ | Python, Data Science, Correlation |
Pet Detection | ✔️ | Python, Data Science, Confusion Matrix |
Marketing Costs | ✔️ | Python, Data Science, Linear Regression |
AB Test | Python, Data Science, Probability, Bayes Law | |
Petri Dish | Python, Data Science, Pearson Correlation | |
Election Poll | ✔️ | Python, Data Science, Descriptive Statistic |
Digits to Employees | ✔️ | Numerical Reasoning |