Skip to content

Solving algorithm problems with C++ (Cmake,gtest), C# (dotnet,xunit), Py (pip,pytest), Js (NodeJS,mocha), bash scripts and github actions, under Win10/OSX/Ubuntu.

License

Notifications You must be signed in to change notification settings

zcemycl/algoTest

Repository files navigation

Algorithm Tests License: MIT Hits

Ubuntu MacOS Win2019
example workflow example workflow example workflow
example workflow example workflow example workflow
example workflow example workflow example workflow
example workflow example workflow example workflow

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.

Structures

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] 

How to start?

  • 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

Contents

:shipit: : Solution | ✔️ : Test | Click on Icon to read the code.

Stanford Algorithm Courses

Click to expand!
Tasks C++ C# Python Topics
Karatsuba Multiplication :shipit: ✔️ Divide and Conquer
Bubble Sort :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Sorting Algorithm
Merge Sort :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Sorting Algorithm, Divide and Conquer
Count Inversions :shipit: ✔️ :shipit: ✔️ Divide and Conquer
Quick Sort :shipit: ✔️ :shipit: ✔️ Sorting Algorithm, Divide and Conquer
N-th Order Statistics :shipit: ✔️ Divide and Conquer, Randomized Algorithm
Minimum Cuts :shipit: ✔️ :shipit: ✔️ Graph, Randomized Algorithm
Breadth First Search :shipit: ✔️ :shipit: ✔️ Graph, BFS, Queue
Shortest Paths :shipit: ✔️ Graph, BFS
Undirected Connectivity :shipit: ✔️ Undirected Graph, BFS
Depth First Search :shipit: ✔️ Graph, DFS
Topological Sort :shipit: ✔️ Directed Acyclic Graph, DFS
Strongly Connected Components :shipit: ✔️ Directed Graph, DFS
Dijkstra Algorithm :shipit: ✔️ Directed Graph, Heap
Heap Array, Heap
Selection Sort Sorting Algorithm
Heap Sort Sorting Algorithm, Heap
Median Maintenance :shipit: ✔️ Heap
Red Black Trees Binary Search Tree
Hash Table Hashmap
Bloom Filters Bloom Filters
Union Find Union Find
Two Sums Hashmap

Leetcode

Click to expand!
Tasks C++ C# Python Topics
ListNode :shipit: ✔️ :shipit: ✔️ Linked List
TreeNode :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Tree
Graph :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Graph (Directed, Undirected)
1* Two Sum :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array, Hash map
2 Add Two Numbers :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Linked List
3* Longest Substring Without Repeating Characters :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ String, Set, Two Pointers, Sliding Window
5* Longest Palindromic Substring :shipit: ✔️ :shipit: ✔️ String
7 Reverse Integer :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
9 Palindrome Number :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
11* Container With Most Water :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array, Pointer
13 Roman to Integer :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
15* 3Sum :shipit: ✔️ Array, Binary Search
17 Letter Combinations of a Phone Number :shipit: DFS
19* Remove Nth Node from End of List :shipit: ✔️ Linked List
20* Valid Parentheses :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Stack, Hashmap, Set
21* Merge Two Sorted Lists :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Linked List
23* Merge K Sorted Lists :shipit: ✔️ Linked List, Heap
26 Remove Duplicates from Sorted Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Pointers, Inplace Operation
27 Remove Element :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Pointers, Inplace Operation
31 Next Permutation :shipit: Pointers
33* Search in Rotated Sorted Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array
34 Find First and Last Position of Element in Sorted Array :shipit: Array, Binary Search
35 Search Insert Position :shipit: ✔️ Two Pointers
36 Valid Sudoku :shipit: ✔️ Set
37 Sudoku Solver :shipit: ✔️ Set
39* Combination Sum :shipit: ✔️ Recursive, DFS, Backtracking
40 Combination Sum II :shipit: DFS
42 Trapping Rain Water :shipit: List
46 Permutations :shipit: ✔️ Recursive, DFS, Backtracking
47 Permutations II :shipit: ✔️ Recursive, DFS, Backtracking
48* Rotate Image :shipit: ✔️ :shipit: ✔️ Matrix
49* Group Anagrams :shipit: ✔️ String, Hashmap
53* Maximum Subarray :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array
54* Spiral Matrix :shipit: ✔️ Matrix
55* Jump Game :shipit: ✔️ Dynamic Programming, Greedy
56* Merge Intervals :shipit: ✔️ Interval
57* Insert Interval :shipit: ✔️ Interval
58 Length of Last Word :shipit: String
62* Unique Paths :shipit: ✔️ Dynamic Programming
63 Unique Paths II :shipit: Dynamic Programming
64 Minimum Path Sum :shipit: ✔️ Dynamic Programming, DFS
66 Plus One :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
68 Text Justification :shipit: String
69 Sqrtx :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Binary Search
70* Climbing Stairs :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Dynamic Programming
73* Set Matrix Zeros :shipit: ✔️ Matrix
74 Search a 2D Matrix :shipit: Binary Search, Matrix
76* Minimum Window Substring :shipit: ✔️ String
77 Combinations :shipit: ✔️ DFS
78 Subsets :shipit: ✔️ DFS
79* Word Search :shipit: ✔️ Matrix
82 Remove Duplicates from Sorted Array 2 :shipit: ✔️ Linked List
90 Subsets II :shipit: ✔️ DFS, Set, Sorting
91* Decode Ways :shipit: ✔️ DFS, Recursive, Dynamic Programming
94 Binary Tree Level Order Traversal :shipit: ✔️ :shipit: ✔️ Binary Tree, Inorder Traversal
98* Validate Binary Search Tree :shipit: ✔️ Binary Search Tree, DFS
100* Same Tree :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Tree
101 Symmetric Tree :shipit: Binary Tree
102* Binary Tree Level Order Traversal :shipit: ✔️ Binary Search Tree, DFS
103 Binary Tree Zigzag Level Order Traversal :shipit: Binary Tree, DFS
104* Maximum Depth of Binary Tree :shipit: ✔️ Binary Tree, Recursion, DFS
105* Construct Binary Tree from Preorder and Inorder Traversal :shipit: ✔️ Binary Tree, DFS
107 Binary Tree Level Order Traversal II :shipit: Binary Tree, DFS
111 Minimum Depth of Binary Tree :shipit: Binary Tree
112 Path Sum :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Tree
118 Pascal's Triangle :shipit: List
119 Pascal's Triangle II :shipit: List
121* Best Time to Buy and Sell Stock :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array
122 Best Time to Buy and Sell Stock II :shipit: Array
124* Binary Tree Maximum Path Sum :shipit: ✔️ Binary Tree
125* Valid Palindrome :shipit: ✔️ String, Two Pointers
128* Longest Consecutive Sequence :shipit: ✔️ Set, Graph
129 Sum Root to Leaf Numbers :shipit: Binary Tree
133* Clone Graph :shipit: ✔️ BFS, Graph
139* Word Break :shipit: ✔️ Recursive, DFS, Dynamic Programming
141* Linked List Cycle :shipit: ✔️ Linked List
142 Linked List Cycle 2 :shipit: ✔️ Linked List
143* Reorder List :shipit: ✔️ Linked List
144 Binary Tree Preorder Traversal :shipit: ✔️ :shipit: ✔️ Binary Tree, Preorder Traversal
145 Binary Tree Postorder Traversal :shipit: ✔️ :shipit: ✔️ Binary Tree, Postorder Traversal
148 Sort List :shipit: Linked List, Divide and Conquer
152* Maximum Product Subarray :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array
153* Find Minimum in Rotated Sorted Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array
167 Two Sum II - Input Array Is Sorted :shipit: ✔️ :shipit: ✔️ Binary Search
182 Duplicate Emails :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ SQL, Sqlite3
190* Reverse Bits :shipit: ✔️ :shipit: ✔️ Bitwise Operation
191* Number of 1 Bits :shipit: ✔️ :shipit: ✔️ Bitwise Operation
193 Valid Phone Numbers Shell, Regular Expression
195 Tenth Line :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Shell
198* House Robber :shipit: ✔️ Dynamic Programming
200* Number of Islands :shipit: ✔️ Graph, DFS
203 Remove Linked List Elements :shipit: ✔️ Linked List
206* Reverse Linked List :shipit: ✔️ Linked List
207* Course Schedule :shipit: ✔️ Graph
208* Implement Trie (Prefix Tree) :shipit: ✔️ Prefix Tree
211* Design Add and Search Words Data Structure :shipit: ✔️ Prefix Tree
212* Word Search II Tree
213* House Robber 2 :shipit: ✔️ Dynamic Programming
216 Combination Sum III :shipit: DFS
217* Contains Duplicate :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array, Set
219 Contains Duplicate 2 :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Hashmap
226* Invert Binary Tree :shipit: ✔️ Binary Tree, DFS
230* Kth Smallest Element in a BST :shipit: ✔️ Binary Search Tree, DFS
235* Lowest Common Ancestor of a Binary Search Tree :shipit: ✔️ Binary Search Tree
238* Product of Array Except Self :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Array
242* Valid Anagram :shipit: ✔️ String, Hashmap
252* Meeting Rooms :shipit: ✔️ Interval
253* Meeting Rooms II :shipit: ✔️ Interval
257 Binary Tree Paths :shipit: Binary Tree
261* Graph Valid Tree :shipit: ✔️ Graph, Tree, DFS
268* Missing Number :shipit: ✔️ :shipit: ✔️ Bitwise Operation
269* Alien Dictionary :shipit: ✔️ Graph, DFS, Topological Sort
271* Encode and Decode Strings :shipit: ✔️ String
295* Find Median from Data Stream :shipit: ✔️ Heap
297* Serialize and Deserialize Binary Tree :shipit: ✔️ Binary Tree, Preorder Traversal
300* Longest Increasing Subsequence :shipit: ✔️ Recursive, DFS, Dynamic Programming
314 Binary Tree Vertical Order Traversal :shipit: Binary Tree, BFS
322* Coin Change :shipit: ✔️ Recursive, DFS, Dynamic Programming
323* Number of Connected Components in an Undirected Graph :shipit: ✔️ DFS, Graph
338* Counting Bits :shipit: ✔️ Bitwise Operation
347* Top K Frequent Elements :shipit: ✔️ Heap
359 Logger Rate Limiter :shipit: Hashmap
366 Find Leaves in Binary Tree :shipit: Binary Tree
371* Sum of Two Integers :shipit: ✔️ :shipit: ✔️ Bitwise Operation
377 Combination Sum IV :shipit: Dynamic Programming
394 Decode String :shipit: ✔️ Stack
404 Sum of Left Leaves :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Tree
417* Pacific Atlantic Water Flow :shipit: ✔️ Graph, DFS
423 Reconstruct Original Digits from English :shipit: DFS
424* Longest Repeating Character Replacement :shipit: ✔️ String, Hashmap, Two Pointers
435* Non-overlapping Intervals :shipit: ✔️ Interval
442 Find All Duplicates in an Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Hashmap
509 Fibonacci Number :shipit: Dynamic Programming
538 Convert BST to Greater Tree :shipit: ✔️ BST, DFS, Recursive
572* Subtree of Another Tree :shipit: ✔️ Binary Tree. DFS
589 N-ary Tree Preorder Traversal :shipit: ✔️ :shipit: ✔️ Tree, Preorder Traversal
590 N-ary Tree Postorder Traversal :shipit: ✔️ :shipit: ✔️ Tree, Postorder Traversal
637 Average of Levels in Binary Tree :shipit: Binary Tree
647* Palindromic Substrings :shipit: ✔️ :shipit: ✔️ String
652 Find Duplicate Subtrees :shipit: Binary Tree, DFS, Hashmap
662 Maximum Width of Binary Tree :shipit: Binary Tree
695 Max Area of Island :shipit: ✔️ Graph, DFS
696 Count Binary Substrings :shipit: List, String
700 Search in a Binary Search Tree :shipit: ✔️ Binary Search Tree
704 Binary Search :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Binary Search
814 Binary Tree Pruning :shipit: ✔️ Binary Tree, DFS
876 Middle of the Linked List :shipit: ✔️ Linked List
912 Sort an Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Sorting Algorithm, Divide and Conquer
938 Range Sum of BST :shipit: ✔️ DFS, Binary Search Tree
973 K Closest Points to Origin :shipit: Heap, Sorting
980 Unique Paths III :shipit: Graph, DFS, Backtracking
989 Add to Array-Form of Integer :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
1009 Complement of Base 10 Integer :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Bitwise Operation
1023 Camelcase Matching :shipit: String
1056 Confusing Number :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Hashmap, Set
1089 Duplicate Zeros :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Inplace Operation
1091 Shortest Path in Binary Matrix :shipit: Graph, Backtracking, BFS
1119 Remove Vowels from a String :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Regular Expression
1143* Longest Common Subsequence :shipit: ✔️ Backtracking, Recursive, Dynamic Programming
1146 Snapshot Array :shipit: Hashmap
1277 Count Square Submatrices with All Ones :shipit: Matrix, Dynamic Programming
1288 Remove Covered Intervals :shipit: Interval
1290 Convert Binary Number in a Linked List to Integer :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Linked List
1293 Shortest Path in a Grid with Obstacles Elimination :shipit: Dynamic Programming, DFS, Graph
1304 Find N Unique Integers Sum up to Zero :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
1356 Sort Integers by The Number of 1 Bits :shipit: ✔️ :shipit: ✔️ Bitwise Operation
1394 Find Lucky Integer in an Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Hashmap
1446 Consecutive Characters :shipit: ✔️
1464 Maximum Product of Two Elements in Array :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Pointers
1518 Water Bottles :shipit:
1592 Rearrange Spaces Between Words :shipit: String
1609 Even Odd Tree :shipit: Binary Tree
1805 Number of Different Integers in a String :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Set
1812 Determine Color of a Chessboard Square :shipit: Hashmap
1836 Remove Duplicates From an Unsorted Linked List :shipit: ✔️ Linked List
1929 Concatenation of Array :shipit: List
2007 Find Original Array From Doubled Array :shipit: Hashmap
2096 Step-By-Step Directions From a Binary Tree Node to Another :shipit: Hashmap, Graph, Binary Tree

Testing Samples

Click to expand!
Tasks C++ C# Python Js Topics
Unit Testing :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Unit Testing
Parameterized Unit Testing :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ Unit Testing
Testing with Fixture :shipit: ✔️ :shipit: ✔️ Unit Testing

HackerRank

Click to expand!
Tasks Language Topics
Height of a Binary Tree :shipit: ✔️ Python Binary Tree
Lowest Common Ancestor :shipit: ✔️ Python Binary Search Tree
Is This a Binary Search Tree? :shipit: ✔️ Python Binary Search Tree
Huffman Decoding :shipit: ✔️ Python Binary Tree

TestDome

Click to expand!
Tasks Topics
League Table :shipit: ✔️ Python, Counter, OrderedDict, Sorting
Ice Cream Machine :shipit: ✔️ Python
Binary Search Tree :shipit: ✔️ Python, NamedTuple, BST
Merge Names :shipit: ✔️ Python, Set
Sorted Search :shipit: ✔️ Python, Binary Search
File Owners :shipit: ✔️ Python
Song :shipit: ✔️ Python, Linked List
Train Composition :shipit: ✔️ Python, Deque
Route Planner :shipit: ✔️ Python, Stack, DFS, Graph
Two Sum :shipit: ✔️ Python
Pipeline :shipit: ✔️ Python, Nested Function
Log Patch :shipit: ✔️ Python, Monkey Patching
Iris Classifier :shipit: ✔️ Python, Data Science, Sklearn
Login Table :shipit: ✔️ Python, Data Science, Pandas
Dog Classification :shipit: ✔️ Python, Data Science, Decision Boundary
Stock Prices :shipit: ✔️ Python, Data Science, Correlation
Pet Detection :shipit: ✔️ Python, Data Science, Confusion Matrix
Marketing Costs :shipit: ✔️ Python, Data Science, Linear Regression
AB Test :shipit: Python, Data Science, Probability, Bayes Law
Petri Dish :shipit: Python, Data Science, Pearson Correlation
Election Poll :shipit: ✔️ Python, Data Science, Descriptive Statistic
Digits to Employees :shipit: ✔️ Numerical Reasoning

Others

Click to expand!
Tasks C++ C# Python Js
Sample :shipit: ✔️ :shipit: ✔️ :shipit: ✔️ :shipit: ✔️
Learn CMake :shipit:
Pointers :shipit: ✔️

About

Solving algorithm problems with C++ (Cmake,gtest), C# (dotnet,xunit), Py (pip,pytest), Js (NodeJS,mocha), bash scripts and github actions, under Win10/OSX/Ubuntu.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published