├── .gitignore ├── Week08 └── README.md ├── googlefa72b21fb50e2d3b.html ├── acm_icpc_prep.jpg ├── Week05 ├── solutions │ ├── herding │ ├── largest_rectangle.py │ ├── stock_span_problem.py │ ├── herding.py │ ├── herding.cpp │ └── hike.py ├── vanilla_implementations │ ├── dfs.py │ └── bfs.py └── README.md ├── Week10 ├── Problems │ ├── Min-Cut_Max-Flow-01.pdf │ ├── Min-Cut_Max-Flow-02.pdf │ └── Min-Cut_Max-Flow-03.pdf └── README.md ├── Week19 └── Readme.md ├── Week01 ├── vanilla_implementations │ ├── modularExponentiation.cpp │ ├── sieve_of_eratosthenes.py │ ├── sieveOfEratosthenes.cpp │ └── primeFactorization.cpp ├── solutions │ ├── distinct_primes.py │ ├── noldbach_problem.py │ ├── tiny_implementation.py │ └── medium_factorization.py └── README.md ├── Week02 ├── solutions │ ├── complicated_gcd.py │ ├── gcd_of_large_number.cc │ ├── modular_gcd.py │ └── sherlock_and_gcd.py ├── vanilla_implementations │ └── gcd_lcm.py └── README.md ├── Week04 ├── solutions │ └── merge_sort_codechef.py ├── vanilla_implementations │ └── merge_sort.py └── README.md ├── Week00 └── README.md ├── Week13 └── Readme.md ├── Week12 ├── README.md └── Source │ └── trie.cpp ├── LICENSE ├── Week11 └── README.md ├── Week07 └── README.md ├── Week03 └── README.md ├── CODE_OF_CONDUCT.md ├── Week06 └── README.md ├── Week09 └── README.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # System 2 | .DS_Store 3 | .vscode 4 | -------------------------------------------------------------------------------- /Week08/README.md: -------------------------------------------------------------------------------- 1 | # Week 8 2 | 3 | 4 | ## Questions from previous topics -------------------------------------------------------------------------------- /googlefa72b21fb50e2d3b.html: -------------------------------------------------------------------------------- 1 | google-site-verification: googlefa72b21fb50e2d3b.html -------------------------------------------------------------------------------- /acm_icpc_prep.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BedirT/ACM-ICPC-Preparation/HEAD/acm_icpc_prep.jpg -------------------------------------------------------------------------------- /Week05/solutions/herding: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BedirT/ACM-ICPC-Preparation/HEAD/Week05/solutions/herding -------------------------------------------------------------------------------- /Week10/Problems/Min-Cut_Max-Flow-01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BedirT/ACM-ICPC-Preparation/HEAD/Week10/Problems/Min-Cut_Max-Flow-01.pdf -------------------------------------------------------------------------------- /Week10/Problems/Min-Cut_Max-Flow-02.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BedirT/ACM-ICPC-Preparation/HEAD/Week10/Problems/Min-Cut_Max-Flow-02.pdf -------------------------------------------------------------------------------- /Week10/Problems/Min-Cut_Max-Flow-03.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BedirT/ACM-ICPC-Preparation/HEAD/Week10/Problems/Min-Cut_Max-Flow-03.pdf -------------------------------------------------------------------------------- /Week19/Readme.md: -------------------------------------------------------------------------------- 1 | # Week 19 2 | 3 | 4 | ## Bit Manipulation 5 | 6 | #### [Tutorial]() 7 | 8 | #### Other Study Sources 9 | - [HackerEarth](https://www.hackerearth.com/practice/notes/bit-manipulation/) 10 | - [InterviewBit](https://www.interviewbit.com/courses/programming/topics/bit-manipulation/) 11 | 12 | #### Full Question Set 13 | - [Geeksforgeeks](https://www.geeksforgeeks.org/bitwise-algorithms/) 14 | -------------------------------------------------------------------------------- /Week01/vanilla_implementations/modularExponentiation.cpp: -------------------------------------------------------------------------------- 1 | // Modular Exponentiation (Power in Modular Aritmetic) (x^y) 2 | #include 3 | using namespace std; 4 | 5 | int main () 6 | { 7 | long long int x,y,mod, res=1; 8 | cin >> x >> y >> mod; 9 | x = x%mod; 10 | while (y > 0) { 11 | if (y%2) 12 | res = (res*x)%mod; 13 | y = y/2; 14 | x= (x*x)%mod; 15 | } 16 | cout << res << endl; 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Week02/solutions/complicated_gcd.py: -------------------------------------------------------------------------------- 1 | # https://codeforces.com/contest/664/problem/A 2 | # 3 | # Author: Bedir Tapkan 4 | 5 | def gcd(a, b): 6 | while b: 7 | a, b = b, a%b 8 | return a 9 | 10 | 11 | def solve(a, b): 12 | cur_gcd = a 13 | for i in range(a+1, b+1): 14 | cur_gcd = gcd(i, cur_gcd) 15 | if cur_gcd == 1: 16 | return 1 17 | return cur_gcd 18 | 19 | 20 | if __name__ == "__main__": 21 | a, b = map(int, input().split(" ")) 22 | print(solve(a,b)) -------------------------------------------------------------------------------- /Week05/solutions/largest_rectangle.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def largestRectangleArea(self, heights: List[int]) -> int: 3 | stack = [] 4 | max_area = 0 5 | 6 | for i, height in enumerate(heights): 7 | s = i 8 | while stack and stack[-1][1] > height: 9 | idx, h = stack.pop() 10 | max_area = max(max_area, h * (i - idx)) 11 | s = idx 12 | stack.append((s, height)) 13 | for idx, h in stack: 14 | max_area = max(max_area, h * (len(heights) - idx)) 15 | return max_area 16 | -------------------------------------------------------------------------------- /Week02/vanilla_implementations/gcd_lcm.py: -------------------------------------------------------------------------------- 1 | # Vanilla implementation of gcd and lcm 2 | # 3 | # Author: Bedir Tapkan 4 | # Date: 04/12/2022 5 | 6 | def gcd(a, b): 7 | """ 8 | Euclidean algorithm implementation 9 | """ 10 | while b: 11 | a, b = b, a % b 12 | return a 13 | 14 | 15 | def lcm(a, b): 16 | """ 17 | Least common multiple implementation 18 | """ 19 | return a * b // gcd(a, b) 20 | 21 | 22 | def example(): 23 | """ 24 | Example 25 | """ 26 | print(gcd(12, 8)) # 4 27 | print(lcm(12, 8)) # 24 28 | 29 | 30 | if __name__ == "__main__": 31 | example() 32 | -------------------------------------------------------------------------------- /Week05/solutions/stock_span_problem.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def stock_span(self, prices): 3 | stack = [] 4 | res = [] 5 | for i, p in enumerate(prices): 6 | res.append(1) # initial val for i 7 | while stack and prices[stack[-1]] <= p: 8 | top = stack.pop() 9 | res[i] += res[top] 10 | stack.append(i) 11 | return res 12 | 13 | # Test 14 | prices = [100, 80, 60, 70, 60, 75, 85] 15 | print(Solution().stock_span(prices)) 16 | 17 | # Output 18 | # [1, 1, 1, 2, 1, 4, 6] 19 | 20 | prices = [10, 4, 5, 90, 120, 80] 21 | print(Solution().stock_span(prices)) 22 | 23 | # Output 24 | # [1, 1, 2, 4, 5, 1] -------------------------------------------------------------------------------- /Week04/solutions/merge_sort_codechef.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | T = int(input()) 3 | 4 | while T: 5 | T -= 1 6 | ct = 1 7 | s, t, i = map(int, input().split()) 8 | if s <= i and i <= t: 9 | print(s, t) 10 | while s != t: 11 | if t-i < i-s: 12 | s = s + int((t-s)/2) + 1 13 | ct += 1 14 | print(s, t) 15 | else: 16 | t = s + int((t-s)/2) 17 | ct += 1 18 | print(s, t) 19 | print(ct) 20 | else: 21 | print(-1) 22 | 23 | 24 | if __name__ == "__main__": 25 | main() -------------------------------------------------------------------------------- /Week00/README.md: -------------------------------------------------------------------------------- 1 | # Heads Up 2 | 3 | What to be familiar with in order to understand later concepts. 4 | 5 | ## Big O notation 6 | 7 | #### Video Sources 8 | - [Youtube - Undefined Behavior](https://www.youtube.com/watch?v=MyeV2_tGqvw) 9 | - [Youtube - Michael Sambol](https://www.youtube.com/watch?v=__vX2sjlpXU) 10 | 11 | #### Written Sources 12 | - [Rob-Bell](https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/) 13 | - [Khan Academy](https://www.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-o-notation) 14 | - [Topcoder Section 1](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20one) 15 | - [Topcoder Section 2](https://www.topcoder.com/thrive/articles/Computational%20Complexity%20part%20two) 16 | -------------------------------------------------------------------------------- /Week13/Readme.md: -------------------------------------------------------------------------------- 1 | # Week 13 2 | 3 | 4 | ## Heaps (Priority Queues) 5 | 6 | #### [Tutorial]() 7 | 8 | #### Other Study Sources 9 | - [HackerEarth](https://www.hackerearth.com/practice/data-structures/trees/heapspriority-queues/tutorial/) 10 | - [GeeksforGeeks](https://www.geeksforgeeks.org/heap-data-structure/) 11 | 12 | #### Questions 13 | - [Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/description/) 14 | - [Java Solution](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/(LeetCode)Kth%20Largest%20Using%20Heaps.java) 15 | - [Merge K Sorted Arrays](https://www.geeksforgeeks.org/merge-k-sorted-arrays/) 16 | - [Median in a stream of integers](https://www.geeksforgeeks.org/median-of-stream-of-integers-running-integers/) 17 | -------------------------------------------------------------------------------- /Week12/README.md: -------------------------------------------------------------------------------- 1 | # Week 12 2 | 3 | 4 | ## Strings 5 | 6 | #### [Tutorial]() 7 | 8 | #### Other Study Sources 9 | 10 | 11 | ## Tries 12 | 13 | #### [Tutorial]() 14 | 15 | #### Other Study Sources 16 | 17 | #### Source Codes 18 | - Sinan - [C++](Source/trie.cpp) 19 | 20 | #### Questions 21 | - [Tries: Contacts](https://www.hackerrank.com/challenges/ctci-contacts) 22 | 23 | ## Suffix Trees/Arrays 24 | 25 | #### [Tutorial]() 26 | 27 | #### Other Study Sources 28 | 29 | #### Source Codes 30 | 31 | #### Questions 32 | 33 | 34 | ## Knuth-Morris-Pratt Algorithm (KMP) 35 | 36 | #### [Tutorial]() 37 | 38 | #### Other Study Sources 39 | 40 | #### Source Codes 41 | 42 | #### Questions 43 | 44 | 45 | ## Rabin-Karp Algorithm 46 | 47 | #### [Tutorial]() 48 | 49 | #### Other Study Sources 50 | 51 | #### Source Codes 52 | 53 | #### Questions 54 | 55 | 56 | -------------------------------------------------------------------------------- /Week02/solutions/gcd_of_large_number.cc: -------------------------------------------------------------------------------- 1 | // Solution for the problem: GCD of large numbers 2 | // https://www.codechef.com/problems/GCD2 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | int gcd(int a, int b) { 11 | if (b == 0) 12 | return a; 13 | else 14 | return gcd(b, a % b); 15 | } 16 | 17 | int main() { 18 | int n; 19 | cin >> n; 20 | for (int i = 0; i < n; ++i) { 21 | int a; 22 | string b; 23 | cin >> a >> b; 24 | if (a == 0) { 25 | cout << b << endl; 26 | continue; 27 | } 28 | int b_mod_a = 0; 29 | for (int j = 0; j < b.size(); ++j) { 30 | b_mod_a = (b_mod_a * 10 + (b[j] - '0')) % a; 31 | } 32 | cout << gcd(a, b_mod_a) << endl; 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /Week01/solutions/distinct_primes.py: -------------------------------------------------------------------------------- 1 | # https://www.spoj.com/problems/AMR11E/ 2 | # 3 | # Author: Bedir Tapkan 4 | 5 | def sieve_of_eratosthenes_modified(n): 6 | """ 7 | Sieve of Eratosthenes implementation 8 | with a tweak: 9 | Instead of true-false calculate the number 10 | of prime numbers to generate the composites. 11 | """ 12 | primes = [0] * (n + 1) 13 | primes[0] = -1 14 | primes[1] = -1 15 | for i in range(2, n + 1): 16 | if not primes[i]: # 0 for prime 17 | for j in range(i + i, n + 1, i): 18 | primes[j] += 1 19 | return [i for i in range(2, n + 1) if primes[i] >= 3] 20 | 21 | 22 | def solution(): 23 | res = sieve_of_eratosthenes_modified(2700) 24 | T = int(input()) 25 | for t in range(T): 26 | n = int(input()) 27 | print(res[n-1]) 28 | 29 | 30 | if __name__ == "__main__": 31 | solution() -------------------------------------------------------------------------------- /Week02/solutions/modular_gcd.py: -------------------------------------------------------------------------------- 1 | # https://www.codechef.com/AUG18B/problems/GCDMOD 2 | # 3 | # Author: Bedir Tapkan 4 | 5 | mod_val = 10**9 + 7 6 | 7 | def gcd(a, b): 8 | while b: 9 | a, b = b, a%b 10 | return a 11 | 12 | def modexp(a, b, x): 13 | a %= x 14 | result = 1 15 | while b > 0: 16 | if b & 1: 17 | result = (result * a) % x 18 | a = a ** 2 % x 19 | b >>= 1 20 | return result 21 | 22 | def solve(a, b, n): 23 | delta = a - b 24 | if delta == 0: 25 | return (modexp(a, n, mod_val) + modexp(b, n, mod_val)) % mod_val 26 | else: 27 | value = modexp(a, n, delta) + modexp(b, n, delta) 28 | value %= delta 29 | return gcd(delta, value) % mod_val 30 | 31 | if __name__ == "__main__": 32 | T = int(input()) 33 | for t in range(T): 34 | a, b, n = map(int, input().split(" ")) 35 | print(solve(a,b,n)) 36 | -------------------------------------------------------------------------------- /Week01/vanilla_implementations/sieve_of_eratosthenes.py: -------------------------------------------------------------------------------- 1 | # Sieve of Eratosthenes implementation in Python 2 | # 3 | # Author: Bedir Tapkan 4 | # Date: 04/11/2022 5 | 6 | def sieve_of_eratosthenes(n): 7 | """ 8 | Sieve of Eratosthenes implementation; 9 | Finding prime numbers from 2 to n (inclusive). 10 | """ 11 | primes = [True] * (n + 1) 12 | primes[0] = False 13 | primes[1] = False 14 | results = [] # List to store the prime numbers 15 | for i in range(2, int(n ** 0.5) + 1): 16 | if primes[i]: 17 | results.append(i) 18 | for j in range(i * i, n + 1, i): 19 | primes[j] = False 20 | return results + [i for i in range(int(n ** 0.5) + 1, n + 1) if primes[i]] 21 | 22 | def main(): 23 | """ 24 | Main function 25 | """ 26 | n = int(input("n: ")) 27 | primes = sieve_of_eratosthenes(n) 28 | print(primes) 29 | 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /Week01/solutions/noldbach_problem.py: -------------------------------------------------------------------------------- 1 | # https://codeforces.com/problemset/problem/17/A 2 | # 3 | # Author: Bedir Tapkan 4 | 5 | def sieveE(n): 6 | primes = [True] * (n + 1) 7 | primes[0] = False 8 | primes[1] = False 9 | prime_nums = [] 10 | for i in range(2, int(n ** 0.5) + 1): 11 | if primes[i]: 12 | prime_nums.append(i) 13 | for j in range(i * i, n + 1 ,i): 14 | primes[j] = False 15 | return prime_nums + [i for i in range(int(n**0.5)+1, n+1) 16 | if primes[i]], primes 17 | # Prime integers, Truth values in a table 18 | 19 | 20 | def noldbach(): 21 | primes, primes_table = sieveE(3500) # 1000+ primes 22 | n, k = map(int, input().split()) 23 | res = 0 24 | for i in range(len(primes)-1): 25 | num_check = primes[i] + primes[i+1] + 1 26 | if num_check > n: 27 | break 28 | if primes_table[num_check]: 29 | res += 1 30 | if res >= k: 31 | print("YES") 32 | else: 33 | print("NO") 34 | 35 | 36 | if __name__=="__main__": 37 | noldbach() 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 NAU-ACM 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Week02/solutions/sherlock_and_gcd.py: -------------------------------------------------------------------------------- 1 | # https://www.hackerrank.com/challenges/sherlock-and-gcd/problem 2 | # 3 | # Author: Bedir Tapkan 4 | 5 | import math 6 | import os 7 | import random 8 | import re 9 | import sys 10 | 11 | # 12 | # Complete the 'solve' function below. 13 | # 14 | # The function is expected to return a STRING. 15 | # The function accepts INTEGER_ARRAY a as parameter. 16 | # 17 | 18 | def gcd(a, b): 19 | while b: 20 | a, b = b, a%b 21 | return a 22 | 23 | def solve(a): 24 | # if all the gcd of all the elements is 1 return 'YES' 25 | # otherwise return 'NO' 26 | a = list(set(a)) 27 | tot_gcd = a[0] 28 | for i in range(1, len(a)): 29 | tot_gcd = gcd(tot_gcd, a[i]) 30 | if tot_gcd > 1: 31 | return 'NO' 32 | return 'YES' 33 | 34 | if __name__ == '__main__': 35 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 36 | 37 | t = int(input().strip()) 38 | 39 | for t_itr in range(t): 40 | a_count = int(input().strip()) 41 | 42 | a = list(map(int, input().rstrip().split())) 43 | 44 | result = solve(a) 45 | 46 | fptr.write(result + '\n') 47 | 48 | fptr.close() 49 | -------------------------------------------------------------------------------- /Week01/solutions/tiny_implementation.py: -------------------------------------------------------------------------------- 1 | # https://wiki.haskell.org/99_questions/Solutions/39 2 | # Finding prime numbers in a range. (Using Sieve of Eratosthenes) 3 | # 4 | # Author: Bedir Tapkan 5 | 6 | def sieve_of_eratosthenes(n): 7 | """ 8 | Sieve of Eratosthenes implementation 9 | """ 10 | primes = [True] * (n + 1) 11 | primes[0] = False 12 | primes[1] = False 13 | results = [] 14 | for i in range(2, int(n ** 0.5) + 1): 15 | if primes[i]: 16 | # i is prime 17 | results.append(i) 18 | for j in range(i * i, n + 1, i): 19 | primes[j] = False 20 | return results + [i for i in range(int(n ** 0.5) + 1, n + 1) if primes[i]] 21 | 22 | 23 | def solution(): 24 | """ 25 | Given a start and an end point, 26 | Prints the prime numbers in between. 27 | """ 28 | _start = int(input("Start: ")) 29 | _end = int(input("End: ")) 30 | res = sieve_of_eratosthenes(_end) 31 | for i, x in enumerate(res): 32 | if x >= _start: 33 | start_idx = i 34 | break 35 | print(res[start_idx:]) 36 | 37 | 38 | if __name__ == "__main__": 39 | solution() 40 | 41 | -------------------------------------------------------------------------------- /Week01/vanilla_implementations/sieveOfEratosthenes.cpp: -------------------------------------------------------------------------------- 1 | // Sieve of Eratosthenes 2 | // 3 | // Author: Bedir Tapkan 4 | // 5 | // Desc: Find the prime numbers from 1 - n 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace std; 12 | 13 | void sieve(long n, bool * composite, vector &primes){ 14 | // n -> the max number to check for primes 15 | // composite -> bool arr to mark composite nums 16 | // primes -> vector that contains primes from 2 -> n 17 | 18 | // O(n*sqrt(n)) - but much faster in practice 19 | for (long i = 2; i <= n; ++i){ 20 | // Check 2->n if they are already marked as composite 21 | // and mark composites along the way 22 | if (!composite[i]){ 23 | // Checking if prime 24 | primes.push_back(i); 25 | for (long j = i*i; j <= n; j += i){ 26 | composite[j] = true; 27 | } 28 | } 29 | } 30 | } 31 | void printVector(vector vc) { 32 | for (int i = 0; i < vc.size(); ++i) 33 | cout << vc[i] << " "; 34 | cout << endl << endl; 35 | } 36 | 37 | int main() { 38 | long n; 39 | cin >> n; // number to check for primes up to 40 | 41 | bool composite[n+1]; 42 | memset(composite, false, sizeof composite); 43 | vector primes; 44 | 45 | sieve(n, composite, primes); 46 | printVector(primes); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Week05/solutions/herding.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | n, m = map(int, input().split()) 3 | graph = [] 4 | for i in range(n): 5 | graph.append(input()) 6 | visited = set() 7 | count = 0 8 | for i in range(n): 9 | for j in range(m): 10 | if (i, j) not in visited: 11 | just_visited = set() 12 | node = (i, j) 13 | while node not in just_visited: 14 | if node in visited: 15 | break 16 | just_visited.add(node) 17 | visited.add(node) 18 | if graph[node[0]][node[1]] == 'N' and node[0] > 0: 19 | node = (node[0]-1, node[1]) 20 | elif graph[node[0]][node[1]] == 'S' and node[0] < n-1: 21 | node = (node[0]+1, node[1]) 22 | elif graph[node[0]][node[1]] == 'E' and node[1] < m-1: 23 | node = (node[0], node[1]+1) 24 | elif graph[node[0]][node[1]] == 'W' and node[1] > 0: 25 | node = (node[0], node[1]-1) 26 | else: 27 | break 28 | if node in just_visited: 29 | count += 1 30 | print(count) 31 | 32 | if __name__ == "__main__": 33 | main() -------------------------------------------------------------------------------- /Week01/solutions/medium_factorization.py: -------------------------------------------------------------------------------- 1 | # https://www.spoj.com/problems/FACTCG2/ 2 | # This is a conceptual code snippet. It won't pass the test cases 3 | # due to language limitations. 4 | # 5 | # Author: Bedir Tapkan 6 | 7 | def sieveE(n): 8 | primes = [0] * (n + 1) 9 | primes[0] = 0 10 | primes[1] = 0 11 | 12 | for i in range(2, n + 1): 13 | if not primes[i]: 14 | for j in range(i * i, n + 1, i): 15 | if not primes[j]: 16 | primes[j] = i # smallest prime factor 17 | return primes 18 | 19 | 20 | def factorize(n, primes): 21 | """ 22 | Return the prime factors of the num n 23 | as string including 1 ie. for n=4; 1 x 2 x 2 24 | """ 25 | factors = ["1"] 26 | while primes[n] != 0 and n % primes[n] == 0: 27 | # n is not prime and n is divisible by f 28 | factors.append(str(primes[n])) 29 | n = n // primes[n] 30 | if n != 1: 31 | factors.append(str(n)) 32 | return " x ".join(factors) 33 | 34 | 35 | def solution(): 36 | # Input is until there is no more input given 37 | # When reached EOF, break 38 | primes = sieveE(10001) 39 | while True: 40 | try: 41 | n = int(input()) 42 | if n == 1: 43 | print("1") 44 | else: 45 | print(factorize(n, primes)) 46 | except EOFError: 47 | break 48 | 49 | 50 | if __name__ == "__main__": 51 | solution() -------------------------------------------------------------------------------- /Week01/vanilla_implementations/primeFactorization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include // STL 5 | #include // STL 6 | 7 | using namespace std; 8 | 9 | vector primes; 10 | 11 | void sieve(int size) { 12 | bitset<10000010> was; 13 | was.set(); 14 | was[0] = was[1] = 0; 15 | for (int i = 2; i <= size; i++) 16 | if (was[i]) { 17 | primes.push_back(i); 18 | for (int j = i * i; j <= size; j += i) was[j] = 0; 19 | } 20 | } 21 | 22 | vector primeFactors(int N){ 23 | vector vc; 24 | // Comment line below for using other method (iterator) 25 | // 26 | int idx = 0, f = primes[idx]; // f standing for FACTOR - idx is index that we will increment 27 | // 28 | // More advanced usage would be pointers : 29 | // vector::iterator it = primes.begin(); int f = *it; ///// Uncomment for using iterator 30 | // 31 | while(N != 1 && N >= f * f){ 32 | while(N % f == 0){ 33 | N /= f; 34 | vc.push_back(f); 35 | } 36 | // 37 | // f = *(++it); ///// Uncomment for using iterator 38 | // 39 | f = primes[++idx]; // Comment this for using other method (iterator) 40 | // 41 | } 42 | if(N != 1) vc.push_back(N); // This case is for prime numbers or having factor greater than sqrt(N). 43 | return vc; 44 | } 45 | 46 | int main(){ 47 | 48 | sieve(10000); 49 | int n = 18; 50 | // cin >> n; 51 | vector pF = primeFactors(n); 52 | for(int i = 0; i < pF.size() ; ++i){ 53 | cout << pF[i] << " " ; 54 | } 55 | cout << endl; 56 | } 57 | -------------------------------------------------------------------------------- /Week05/vanilla_implementations/dfs.py: -------------------------------------------------------------------------------- 1 | # Depth First Search (DFS) implementation 2 | # 3 | # A simple implementation of DFS using a queue 4 | # with in depth comments 5 | # 6 | # Author: BedirT 7 | 8 | def dfs(graph, start, goal): 9 | # Initialize a stack with the start node 10 | stack = [start] 11 | # Initialize a set to keep track of visited nodes 12 | visited = set() 13 | # Create a list to keep track of the order in which we visit the nodes 14 | # This is not necessary for the algorithm to work visited set is enough 15 | # But it is useful for visualization 16 | order = [] 17 | # While the stack is not empty 18 | while stack: 19 | # Pop the last element from the stack 20 | node = stack.pop() 21 | # If the node has not been visited 22 | if node not in visited: 23 | # Mark the node as visited 24 | visited.add(node) 25 | # Add the node to the order list 26 | order.append(node) 27 | # If the node is the goal, return the path 28 | if node == goal: 29 | return order 30 | # Add the neighbors of the node to the stack 31 | stack.extend(graph[node]) 32 | # If the stack is empty, return None 33 | return None 34 | 35 | 36 | if __name__ == "__main__": 37 | # Example usage 38 | graph = { 39 | 'A': ['B', 'C'], 40 | 'B': ['A', 'D', 'E'], 41 | 'C': ['A', 'F'], 42 | 'D': ['B'], 43 | 'E': ['B', 'F'], 44 | 'F': ['C', 'E'] 45 | } 46 | print(dfs(graph, 'A', 'F')) 47 | 48 | # Output: ['A', 'C', 'F'] 49 | 50 | # Another example 51 | graph = { 52 | 'A': ['B', 'C'], 53 | 'B': ['A'], 54 | 'C': ['A'], 55 | 'G': ['H'], 56 | 'H': ['G'] 57 | } 58 | print(dfs(graph, 'A', 'H')) 59 | 60 | # Output: None -------------------------------------------------------------------------------- /Week05/vanilla_implementations/bfs.py: -------------------------------------------------------------------------------- 1 | # Breadth First Search (BFS) implementation 2 | # 3 | # A simple implementation of BFS using a queue 4 | # with in depth comments 5 | # 6 | # Author: BedirT 7 | 8 | def bfs(graph, start, goal): 9 | # Initialize a queue with the start node 10 | queue = [start] 11 | # Initialize a set to keep track of visited nodes 12 | visited = set() 13 | # Create a list to keep track of the order in which we visit the nodes 14 | # This is not necessary for the algorithm to work visited set is enough 15 | # But it is useful for visualization 16 | order = [] 17 | # While the queue is not empty 18 | while queue: 19 | # Pop the first element from the queue 20 | node = queue.pop(0) 21 | # If the node has not been visited 22 | if node not in visited: 23 | # Mark the node as visited 24 | visited.add(node) 25 | # Add the node to the order list 26 | order.append(node) 27 | # If the node is the goal, return the path 28 | if node == goal: 29 | return order 30 | # Add the neighbors of the node to the queue 31 | queue.extend(graph[node]) 32 | # If the queue is empty, return None 33 | return None 34 | 35 | 36 | if __name__ == "__main__": 37 | # Example usage 38 | graph = { 39 | 'A': ['B', 'C'], 40 | 'B': ['A', 'D', 'E'], 41 | 'C': ['A', 'F'], 42 | 'D': ['B'], 43 | 'E': ['B', 'F'], 44 | 'F': ['C', 'E'] 45 | } 46 | print(bfs(graph, 'A', 'F')) 47 | 48 | # Output: ['A', 'B', 'C', 'D', 'E', 'F'] 49 | 50 | # Another example 51 | graph = { 52 | 'A': ['B', 'C'], 53 | 'B': ['A'], 54 | 'C': ['A'], 55 | 'G': ['H'], 56 | 'H': ['G'] 57 | } 58 | print(bfs(graph, 'A', 'H')) 59 | 60 | # Output: None 61 | 62 | -------------------------------------------------------------------------------- /Week05/solutions/herding.cpp: -------------------------------------------------------------------------------- 1 | // Same as the python solution, but in C++. 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | int n, m; 11 | cin >> n >> m; 12 | vector graph; 13 | for (int i = 0; i < n; i++) { 14 | string s; 15 | cin >> s; 16 | graph.push_back(s); 17 | } 18 | set> visited; 19 | int count = 0; 20 | for (int i = 0; i < n; i++) { 21 | for (int j = 0; j < m; j++) { 22 | if (visited.find({i, j}) == visited.end()) { 23 | set> just_visited; 24 | pair node = {i, j}; 25 | while (just_visited.find(node) == just_visited.end()) { 26 | if (visited.find(node) != visited.end()) { 27 | break; 28 | } 29 | just_visited.insert(node); 30 | visited.insert(node); 31 | if (graph[node.first][node.second] == 'N' && node.first > 0) { 32 | node = {node.first-1, node.second}; 33 | } else if (graph[node.first][node.second] == 'S' && node.first < n-1) { 34 | node = {node.first+1, node.second}; 35 | } else if (graph[node.first][node.second] == 'E' && node.second < m-1) { 36 | node = {node.first, node.second+1}; 37 | } else if (graph[node.first][node.second] == 'W' && node.second > 0) { 38 | node = {node.first, node.second-1}; 39 | } else { 40 | break; 41 | } 42 | } 43 | if (just_visited.find(node) != just_visited.end()) { 44 | count += 1; 45 | } 46 | } 47 | } 48 | } 49 | cout << count << endl; 50 | return 0; 51 | } -------------------------------------------------------------------------------- /Week12/Source/trie.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | struct Node 7 | { 8 | bool isEnd; 9 | Node* child[26]; 10 | 11 | Node() 12 | { 13 | isEnd = false; 14 | memset(child, 0, sizeof(child)); 15 | } 16 | }; 17 | 18 | Node* root = new Node(); 19 | 20 | void add(const string& str) 21 | { 22 | auto node = root; 23 | 24 | for(int i = 0; i < str.length(); i++) 25 | { 26 | if(node->child[str[i] - 'a'] != nullptr) 27 | { 28 | node = node->child[str[i] - 'a']; 29 | } 30 | else 31 | { 32 | node->child[str[i] - 'a'] = new Node(); 33 | 34 | if(i == str.length() - 1) 35 | { 36 | node->child[str[i] - 'a']->isEnd = true; 37 | return; 38 | } 39 | 40 | node = node->child[str[i] - 'a']; 41 | } 42 | } 43 | } 44 | 45 | bool find(const string& str) 46 | { 47 | auto node = root; 48 | 49 | for(int i = 0; i < str.length(); i++) 50 | { 51 | if(node->child[str[i] - 'a'] != nullptr) 52 | { 53 | node = node->child[str[i] - 'a']; 54 | } 55 | else 56 | { 57 | return false; 58 | } 59 | } 60 | 61 | return node->isEnd; 62 | } 63 | 64 | int main() 65 | { 66 | // Number of queries 67 | int n; 68 | cin >> n; 69 | for(int i = 0; i < n; i++) 70 | { 71 | // 1: add a new word 72 | // 2: search for an existing word 73 | int option; 74 | string word; 75 | cin >> option >> word; 76 | 77 | if(option == 1) 78 | { 79 | add(word); 80 | } 81 | else if(option == 2) 82 | { 83 | cout << (find(word) ? "Found" : "Not found") << endl; 84 | } 85 | else 86 | { 87 | continue; 88 | } 89 | } 90 | 91 | return 0; 92 | } -------------------------------------------------------------------------------- /Week04/vanilla_implementations/merge_sort.py: -------------------------------------------------------------------------------- 1 | # Merge Sort implementation in Python with in depth comments 2 | # 3 | # Author: BedirT 4 | 5 | # Merge Sort is a divide and conquer algorithm that divides the input array into two halves, 6 | # calls itself for the two halves, and then merges the two sorted halves. The merge() 7 | # function is used for merging two halves. The merge(arr, l, m, r) is key process that 8 | # assumes that arr[l..m] and arr[m+1..r] are sorted and merges the two sorted sub-arrays into one. 9 | 10 | # Time Complexity: O(nlogn) 11 | # Space Complexity: O(n) 12 | 13 | def merge_sort(arr): 14 | if len(arr) > 1: 15 | # Finding the mid of the array 16 | mid = len(arr) // 2 17 | 18 | # Dividing the array elements 19 | L = arr[:mid] 20 | 21 | # into 2 halves 22 | R = arr[mid:] 23 | 24 | # Sorting the first half 25 | merge_sort(L) 26 | 27 | # Sorting the second half 28 | merge_sort(R) 29 | 30 | i = j = k = 0 31 | 32 | # Copy data to temp arrays L[] and R[] 33 | while i < len(L) and j < len(R): 34 | if L[i] < R[j]: 35 | arr[k] = L[i] 36 | i += 1 37 | else: 38 | arr[k] = R[j] 39 | j += 1 40 | k += 1 41 | 42 | # Checking if any element was left 43 | while i < len(L): 44 | arr[k] = L[i] 45 | i += 1 46 | k += 1 47 | 48 | while j < len(R): 49 | arr[k] = R[j] 50 | j += 1 51 | k += 1 52 | 53 | 54 | # Code to print the list 55 | def print_list(arr): 56 | for i in range(len(arr)): 57 | print(arr[i], end=" ") 58 | print() 59 | 60 | 61 | # Driver Code 62 | if __name__ == '__main__': 63 | arr = [12, 11, 13, 5, 6, 7] 64 | print("Given array is", end="\n") 65 | print_list(arr) 66 | merge_sort(arr) 67 | print("Sorted array is: ", end="\n") 68 | print_list(arr) 69 | -------------------------------------------------------------------------------- /Week11/README.md: -------------------------------------------------------------------------------- 1 | # Week 11 2 | 3 | 4 | ## Geometry (Primitive Operations) 5 | 6 | #### [Tutorial]() 7 | 8 | #### Other Study Sources 9 | - [Geometric Algorithms Slayt](https://www.cs.princeton.edu/~rs/AlgsDS07/16Geometric.pdf) 10 | - [GeeksforGeeks - Polygon Inside](http://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/) 11 | - [GeeksforGeeks - Line Intersect](http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/) 12 | - [Small Video](https://www.youtube.com/watch?v=R08OY6yDNy0) (_About 8 min_) 13 | - [GeeksforGeeks](http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/) 14 | 15 | 16 | ### Line intersection 17 | 18 | #### Source Codes 19 | - Bedir - [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Geometry/geo_lineIntersection.cpp) 20 | - Nadide - [C++](https://github.com/nadide/ACM-ICPC/blob/master/codes/geo_lineIntersect.cpp) 21 | 22 | 23 | ### Polygon Inside, Outside 24 | 25 | #### Source Codes 26 | - Bedir - [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Geometry/geo_polygonInsideOrOutside.cpp) 27 | - Nadide - [C++](https://github.com/nadide/ACM-ICPC/blob/master/codes/geo_polygonInside.cpp) 28 | 29 | 30 | 31 | ## Convex Hull (Jarvis's Algorithm) 32 | 33 | #### [Tutorial]() 34 | 35 | #### Other Study Sources 36 | - [GeeksforGeeks](http://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/) 37 | - [Explanatory video](https://www.youtube.com/watch?v=wkEZ2gWfSIc) 38 | 39 | #### Source Codes 40 | - [Bedir](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Geometry/geo_convexHull.cpp) 41 | - [Nadide](https://github.com/nadide/ACM-ICPC/blob/master/codes/geo_convexHull.cpp) 42 | 43 | #### Questions 44 | - [Timus asking - Convex Hull ](http://acm.timus.ru/problem.aspx?space=1&num=1305) 45 | 46 | 47 | 48 | ## Closest pair problem 49 | 50 | #### [Tutorial]() 51 | 52 | #### Other Study Sources 53 | 54 | #### Source Codes 55 | 56 | #### Questions 57 | 58 | 59 | -------------------------------------------------------------------------------- /Week05/solutions/hike.py: -------------------------------------------------------------------------------- 1 | # Solving HIKE problem on SPOJ 2 | # Note: This solution will not pass SPOJ's time limit due to the use of Python 3 | # The solution is correct however SPOJ has very slow Python interpreters 4 | 5 | import sys 6 | 7 | mx_number = int(1e9) 8 | 9 | def solution(): 10 | # Read the input until we don't get any more 11 | while True: 12 | # Read the input 13 | line = input() 14 | # If n is 0, we are done 15 | if line == '0': 16 | break 17 | # Split the line into a list of strings 18 | n, p1, p2, p3 = map(int, line.split()) 19 | # Create a list of lists to hold the graph 20 | graph = [] 21 | # Read the graph 22 | for i in range(n): 23 | graph.append(list(input().split())) 24 | # Queue for BFS 25 | queue = [] 26 | # Add the starting nodes for each player to the queue 27 | queue.extend([p1-1, p2-1, p3-1]) # players are 1-indexed 28 | # Create distance list, nxnxn 29 | distance = [[[mx_number for i in range(n)] for j in range(n)] for k in range(n)] 30 | # Set the distance of the starting nodes to 0 31 | distance[p1-1][p2-1][p3-1] = 0 32 | # While there are still nodes in the queue 33 | while queue: 34 | a = queue.pop(0) 35 | b = queue.pop(0) 36 | c = queue.pop(0) 37 | for i in range(n): 38 | # If the color of the edge between a and i is the same as the color of the edge 39 | # between b and c, then we can move a to i. We update the distance and add the 40 | # new nodes to the queue only if the distance is less than the current distance. 41 | # We do this for all three players. 42 | if graph[a][i] == graph[b][c] and distance[a][b][c] + 1 < distance[i][b][c]: 43 | distance[i][b][c] = distance[a][b][c] + 1 44 | queue.extend([i, b, c]) 45 | if graph[b][i] == graph[a][c] and distance[a][b][c] + 1 < distance[a][i][c]: 46 | distance[a][i][c] = distance[a][b][c] + 1 47 | queue.extend([a, i, c]) 48 | if graph[c][i] == graph[a][b] and distance[a][b][c] + 1 < distance[a][b][i]: 49 | distance[a][b][i] = distance[a][b][c] + 1 50 | queue.extend([a, b, i]) 51 | # If the distance from the starting nodes to the same node is less than infinity, then 52 | # we can get all three players to the same node. Otherwise, we can't. 53 | res = mx_number 54 | for i in range(n): 55 | res = min(res, distance[i][i][i]) 56 | if res == mx_number: 57 | print('impossible') 58 | else: 59 | print(res) 60 | 61 | 62 | if __name__ == "__main__": 63 | solution() 64 | -------------------------------------------------------------------------------- /Week07/README.md: -------------------------------------------------------------------------------- 1 | # Week 7 2 | 3 | 4 | ## Knapsack 5 | 6 | > [Tutorial]() 7 | 8 | #### Other Study Sources 9 | - [GeeksforGeeks](http://www.geeksforgeeks.org/dynamic-programming-set-10-0-1-knapsack-problem/) 10 | - [Youtube - CS Dojo](https://www.youtube.com/watch?v=xOlhR_2QCXY) 11 | 12 | #### Source Codes 13 | - [BedirT - Optimized Knapsack](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Dynamic/Optimized%20Knapsack.cpp) 14 | - [BedirT - Knapsack](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Dynamic/Knapsack%20Algorithm.cpp) 15 | - [Java Solution Using Top Down Memoization DP](https://github.com/rajat123456/Dynamic-Programming/blob/master/01%20Knapsack/Using%20Top%20Down%20Memoization%20DP.java) 16 | 17 | #### Questions 18 | - [13-Dots](https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1760) 19 | 20 | 21 | ## Coin Change 22 | 23 | > [Tutorial]() 24 | 25 | #### Other Study Sources 26 | - [Youtube - ONeill Code](https://www.youtube.com/watch?v=jaNZ83Q3QGc&t=205s) 27 | 28 | #### Source Codes 29 | - [BedirT](https://github.com/NAU-ACM/ICPC-Question-Solving/blob/master/BedirT/Chapter%203/UVa%20-%2000357.cpp) 30 | 31 | #### Questions 32 | - [Let me count the ways](https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=293) 33 | - [Bedir's solution](https://github.com/NAU-ACM/ICPC-Question-Solving/blob/master/BedirT/Chapter%203/UVa%20-%20357.cpp) 34 | 35 | 36 | ## Kadane 37 | 38 | > [Tutorial](http://bedirtapkan.com/Kadane's-Algorithm/) 39 | 40 | #### Other Study Sources 41 | - [GeeksforGeeks](http://www.geeksforgeeks.org/largest-sum-contiguous-subarray/) 42 | - [Youtube - Coding Interview Hub](https://www.youtube.com/watch?v=86CQq3pKSUw) 43 | 44 | #### Source Codes 45 | - [Bedir's Code](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Dynamic/Kadane's%20Algorithm.cpp) 46 | 47 | #### Questions 48 | - [Maximum Sub-sequence Product](https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=728&mosmsg=Submission+received+with+ID+18120191) 49 | - [Bedir's Solution](https://github.com/BedirT/Algorithms_and_DS/blob/master/Problems/Curriculum%20Q's/Week%2010/Maximum%20Sub-sequence%20Product.cpp) 50 | - [The jackpot](https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1625) 51 | - [Garbage Heap](https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1696) 52 | - [Hotels Along the Croatian Coast](http://www.spoj.com/problems/HOTELS/) 53 | - [Maximum Sum](http://acm.timus.ru/problem.aspx?space=1&num=1146) 54 | - [Maximum Subrarray](https://www.hackerrank.com/challenges/maxsubarray) 55 | - [Bedir's Solution](https://github.com/BedirT/Algorithms_and_DS/blob/master/Problems/HackerRank/Algorithms/Dynamic%20Programming/Maximum%20Subarray.cpp) 56 | -------------------------------------------------------------------------------- /Week10/README.md: -------------------------------------------------------------------------------- 1 | # Week 10 2 | 3 | 4 | ## Bellman Ford 5 | 6 | #### [Tutorial]() 7 | 8 | #### Other Study Sources 9 | - [Youtube - Michael Sambol - Theory](https://www.youtube.com/watch?v=9PHkk0UavIM) [Youtube - Michael Sambol - Example](https://www.youtube.com/watch?v=obWXjtg0L64) 10 | - [GeeksforGeeks](http://www.geeksforgeeks.org/dynamic-programming-set-23-bellman-ford-algorithm/) 11 | - [Stackoverflow - Difference Between Djikstra & Bellman Ford](http://stackoverflow.com/questions/16273092/difference-between-bellman-ford-and-dijkstras-algorithm) 12 | 13 | #### Source Codes 14 | - Bedir - [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Graph/FBellman_own.cpp) 15 | - Nadide - [C++](https://github.com/nadide/ACM-ICPC/blob/master/codes/dynamic_bellmanFord.cpp) 16 | 17 | #### Questions 18 | - [Travel Company](http://www.lightoj.com/volume_showproblem.php?problem=1221) 19 | - [Instant View of Big Bang](http://www.lightoj.com/volume_showproblem.php?problem=1108) 20 | 21 | 22 | 23 | ## Max Flow / Min Cut 24 | 25 | #### [Tutorial](https://irasuna.github.io/2016/network-flow/) 26 | 27 | #### Other Study Sources 28 | - [GeeksforGeeks](http://www.geeksforgeeks.org/ford-fulkerson-algorithm-for-maximum-flow-problem/) 29 | - [Youtube - Introduction to Network Flow and Ford-Fulkerson Algorithm](https://www.youtube.com/watch?v=_G6_-ljgmXE) 30 | 31 | #### Source Codes 32 | - [Bedir - C++](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Graph/Ford%20Fulkerson.cpp) (Both DFS and BFS versions) 33 | 34 | #### Questions 35 | - [Arya Revenge](Problems/Min-Cut_Max-Flow-01.pdf) 36 | - [Internet Bandwidth](Problems/Min-Cut_Max-Flow-02.pdf) 37 | - [March of the Penguins](Problems/Min-Cut_Max-Flow-03.pdf) 38 | 39 | 40 | 41 | ## Longest increasing Subsequence (with RMQ) 42 | 43 | #### [Tutorial]() 44 | 45 | #### Other Study Sources 46 | - [GeeksforGeeks](http://www.geeksforgeeks.org/dynamic-programming-set-3-longest-increasing-subsequence/) 47 | - [GeeksforGeeks-nlogn](http://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/) 48 | 49 | #### Source Codes 50 | - [Bedir - Dynamic solution](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Dynamic/LIS_Dynamic.cpp) _Complexity is O(n^2)_ 51 | - [Bedir - O(nlogn) solution](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Dynamic/LIS_nLogn.cpp) _This is not a Dynamic approach but it is more efficient_ 52 | 53 | #### Questions 54 | - [The Longest Increasing Subsequence](https://www.hackerrank.com/challenges/longest-increasing-subsequent) 55 | - [Bedir's Solution](https://github.com/BedirT/Algorithms_and_DS/blob/master/Problems/HackerRank/Algorithms/Dynamic%20Programming/The%20Longest%20Increasing%20Subsequence.cpp) 56 | - [Another Longest Increasing Subsequence Problem](http://www.spoj.com/problems/LIS2/) 57 | - [Bedir's Solution](https://github.com/BedirT/Algorithms_and_DS/blob/master/Problems/Curriculum%20Q's/Week%2010/LIS2.cpp) 58 | - [Longest Increasing Subsequences](https://www.codechef.com/problems/MAKELIS) 59 | -------------------------------------------------------------------------------- /Week03/README.md: -------------------------------------------------------------------------------- 1 | # Week 3 2 | 3 | ## QuickSort 4 | 5 | #### Video Sources 6 | - [CS50](https://www.youtube.com/watch?v=aQiWF4E8flQ) 7 | 8 | #### Written Sources 9 | - [algolist.net](http://www.algolist.net/Algorithms/Sorting/Quicksort) 10 | - [GeeksforGeeks](http://quiz.geeksforgeeks.org/quick-sort/) 11 | - [Topcoder](https://www.topcoder.com/thrive/articles/Sorting) 12 | 13 | #### Source Codes 14 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Sorting/qSort.cpp) 15 | - C | [s1](https://github.com/nadide/ACM-ICPC/blob/master/codes/sort_quickSort.c) 16 | 17 | #### Questions 18 | - [Quicksort 1 - Partition](https://www.hackerrank.com/challenges/quicksort1) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Sorting/Quicksort%201%20-%20Partition.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/quickSort1_partition.c) 19 | - [Quicksort 2 - Sorting](https://www.hackerrank.com/challenges/quicksort2) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Sorting/Quicksort%202%20-%20Sorting.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/quickSort2_sorting.c) 20 | - [Quicksort In-Place ](https://www.hackerrank.com/challenges/quicksort3) | [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/quickSort_inPlace.c) 21 | 22 | 23 | ## Counting Sort 24 | 25 | #### Video Sources 26 | - [Edutechional](https://www.youtube.com/watch?v=zhDmVF_NdjM) 27 | - [Yusuf Shakeel](https://www.youtube.com/watch?v=TTnvXY82dtM) 28 | 29 | #### Written Sources 30 | - [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort) 31 | - [GeeksforGeeks](http://www.geeksforgeeks.org/counting-sort/) 32 | 33 | #### Source Codes 34 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Sorting/countingSort.cpp) 35 | - C | [s1](https://github.com/nadide/ACM-ICPC/blob/master/codes/sort_countingSort.c) 36 | 37 | #### Questions 38 | - [Counting Sort 1](https://www.hackerrank.com/challenges/countingsort1) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Sorting/Counting%20Sort%201.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/countingSort1.c) 39 | - [Counting Sort 2](https://www.hackerrank.com/challenges/countingsort2) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Sorting/Counting%20Sort%202.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/countingSort2.c) 40 | - [Counting Sort 3](https://www.hackerrank.com/challenges/countingsort3) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Sorting/Counting%20Sort%203.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/countingSort3.c) 41 | - [The Full Counting Sort](https://www.hackerrank.com/challenges/countingsort4) | [Java](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Sorting/CountingSort4.java), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/sorting/theFullCountingSort.c) 42 | -------------------------------------------------------------------------------- /Week04/README.md: -------------------------------------------------------------------------------- 1 | # Week 4 2 | 3 | ## Merge Sort 4 | 5 | #### Video Sources 6 | - [Youtube - Michael Sambol (3 min)](https://www.youtube.com/watch?v=4VqmGXwpLqc) 7 | - [Hackerrank](https://www.youtube.com/watch?v=KF2j-9iSf4Q) 8 | - [CS50](https://www.youtube.com/watch?v=Pr2Jf83_kG0) 9 | 10 | #### Written Sources 11 | - [CommonLounge - Nicetut](https://www.commonlounge.com/discussion/fe6ac441785c44d6a959eab662f15adc) 12 | - [GeeksforGeeks](https://www.geeksforgeeks.org/merge-sort/) 13 | 14 | #### Source Codes 15 | - [Python](vanilla_implementations/merge_sort.py) 16 | 17 | #### Questions 18 | - [MERGESORT](http://www.spoj.com/problems/MERGSORT/) | (_Same as the source code_) 19 | - [Merge Sort](https://www.codechef.com/problems/MRGSRT) | [Python](solutions/merge_sort_codechef.py) 20 | - [Counting Inversions in an Array](https://www.spoj.com/problems/INVCNT/) | [Java](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/SPOJ(INVCNT).java) 21 | - [Maximum SubArray](https://leetcode.com/problems/maximum-subarray/description/) | [Java](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/(LeetCode)Maximum%20Sum%20Subaray.java) 22 | 23 | ## Binary Search 24 | 25 | #### Video Sources 26 | - [Youtube - Reallearning](https://www.youtube.com/watch?v=vohuRrwbTT4) 27 | 28 | #### Written Sources 29 | - [Topcoder](https://www.topcoder.com/community/data-science/data-science-tutorials/binary-search/) 30 | - [Wikipedia](https://en.wikipedia.org/wiki/Binary_search_algorithm) 31 | - [Interview Cake](https://www.interviewcake.com/concept/java/binary-search) 32 | 33 | #### Source Codes 34 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Searching/binarySearch.cpp) 35 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/search_binarySearch.c) 36 | 37 | #### Questions 38 | - Small interview question that will make you practice this topic: [Ordered Set](https://www.interviewcake.com/question/python/find-in-ordered-set) 39 | - ( _Same as the source code_ ) 40 | - [Search Insert Position](https://leetcode.com/problems/search-insert-position/) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%203/Search%20Insert%20Position.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/other/insertPosition.c) 41 | - [10 beautiful practice question](http://www.infoarena.ro/blog/binary-search-shortlist) | [C++](https://github.com/BedirT/AlgorithmsL/tree/master/Problems/Curriculum%20Q's/Week%203/Binary%20Search%20Shortlist) 42 | - [Ice Cream Parlor](https://www.hackerrank.com/challenges/icecream-parlor) | [C++](https://github.com/NAU-ACM/Competitive-Programming/blob/master/HackerRank/Practices/Algorithms/Search/Ice%20Cream%20Parlor.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/X_iceCreamParlor.c) 43 | - [Maximum Subarray Sum](https://www.hackerrank.com/challenges/maximum-subarray-sum) | [C++](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/X_maximumSubarraySum.cpp) 44 | - [Aggressive Cows](https://www.spoj.com/problems/AGGRCOW/) | [Java](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/(SPOJ)Aggressive%20Cows.java) 45 | -------------------------------------------------------------------------------- /Week02/README.md: -------------------------------------------------------------------------------- 1 | # Week 2 2 | 3 | ## GCD and LCM Euclid’s Algorithm 4 | 5 | #### Video Sources 6 | - [Youtube - Proof of Concept (GCD, LCM)](https://www.youtube.com/watch?v=XeaYoq54rCg) 7 | - [Youtube - Proof of Concept (Euclid's Algorithm)](https://www.youtube.com/watch?v=Jwf6ncRmhPg) 8 | 9 | #### Written Sources 10 | - [GeeksforGeeks](https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/) 11 | - [Wikipedia](https://en.wikipedia.org/wiki/Euclidean_algorithm) 12 | 13 | ### Greatest Common Division (GCD) 14 | 15 | #### Source Codes 16 | - Python | [s0](vanilla_implementations/gcd_lcm.py) 17 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Math/GCD%20and%20LCM%20Euclid%20Algorithm.cpp) 18 | 19 | #### Questions 20 | - [Sherlock and GCD](https://www.hackerrank.com/challenges/sherlock-and-gcd/problem?h_r=internal-search) | [Python](solutions/sherlock_and_gcd.py), [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Math/Sherlock%20and%20GCD.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/mathematics/sherlockAndGCD.c) 21 | - [Complicated GCD](http://codeforces.com/contest/664/problem/A) | [Python](solutions/complicated_gcd.py), [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%201/Complicated%20GCD.cpp) 22 | 23 | ### Least Common Multiple (LCM) 24 | 25 | #### Source Codes 26 | - Python | [s0](vanilla_implementations/gcd_lcm.py) 27 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Math/GCD%20and%20LCM%20Euclid%20Algorithm.cpp), [s1](https://github.com/nadide/ACM-ICPC/blob/master/codes/math_LCM.cpp) 28 | 29 | #### Questions 30 | - [Nth Magical Number](https://leetcode.com/problems/nth-magical-number/) 31 | - [Ugly Number](https://leetcode.com/problems/ugly-number-iii/) 32 | 33 | 34 | ## Long Arithmetic (Multi, Sum, Sub) 35 | 36 | #### Written Sources 37 | - [HackerEarth](https://www.hackerearth.com/practice/notes/get-the-modulo-of-a-very-large-number-that-cannot-be-stored-in-any-data-type-in-cc-1/) 38 | 39 | #### Source Codes *(Summation)* 40 | - C++ | [s0](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Math/extra_long_sum.cpp) 41 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/math_longArithmatic_Add.c) 42 | 43 | #### Source Codes *(Substraction)* 44 | - C++ | [s0](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Math/extra_long_sub.cpp) 45 | 46 | #### Source Codes *(Multiplication)* 47 | - C++ | [s0](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Math/extra_long_mult.cpp) 48 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/math_longArithmatic_Mult.c) 49 | 50 | #### Questions 51 | - [Extra Long Factorials](https://www.hackerrank.com/challenges/extra-long-factorials/problem?h_r=internal-search) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Implementation/Extra%20Long%20Factorial.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/extraLongFactorials.c) 52 | - [GCD of Large Number](https://www.codechef.com/problems/GCD2) | [C++](solutions/gcd_of_large_number.cc) 53 | - [Modular GCD](https://www.codechef.com/AUG18B/problems/GCDMOD) | [Python](solutions/modular_gcd.py) 54 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at acm@na.edu. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /Week01/README.md: -------------------------------------------------------------------------------- 1 | # Week 1 2 | 3 | 4 | ## Prime Numbers (Sieve of Eratosthenes) 5 | 6 | #### Video Sources 7 | - [Youtube - Region 10 ESC](https://www.youtube.com/watch?v=V08g_lkKj6Q) 8 | 9 | #### Written Sources 10 | - [GeeksForGeeks](http://www.geeksforgeeks.org/sieve-of-eratosthenes/) 11 | - [Brilliant](https://brilliant.org/wiki/sieve-of-eratosthenes/) 12 | 13 | #### Source Codes 14 | - Python | [s0](vanilla_implementations/sieve_of_eratosthenes.py) 15 | - C++ | [s0](vanilla_implementations/sieveOfEratosthenes.cpp) 16 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/math_primeNumbers.c) 17 | - Java | [s0](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/Sieve%20of%20Eratosthenes.java) 18 | 19 | #### Questions 20 | - [Tiny Implementation](https://wiki.haskell.org/99_questions/Solutions/39) | [Python](solutions/tiny_implementation.py), [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%204/sieve%20question.cpp), [Java](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/Prime%20within%20Range.java) 21 | - [Distinct Primes](http://www.spoj.com/problems/AMR11E/) | [Python](solutions/distinct_primes.py), [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%204/AMR11E%20-%20Distinct%20Primes.cpp), [Java](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/SPOJ(Distinct%20Primes).java) 22 | - [Noldbach problem](http://codeforces.com/problemset/problem/17/A?locale=en) | [Python](solutions/noldbach_problem.py), [C++](https://github.com/NAU-ACM/Competitive-Programming/blob/master/CodeForces/Practices/Noldbach%20problem.cpp), [Java](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/Codeforces(Noldbach%20Problem).java) 23 | 24 | 25 | 26 | ## Efficient Prime Factorization 27 | 28 | #### Written Sources 29 | - [Stackoverflow - Check Answers](http://stackoverflow.com/questions/26344081/efficient-prime-factorization-for-large-numbers) 30 | - [Competitive Programming 3 by Steven & Felix Halim - Page 212](https://www.amazon.com/Competitive-Programming-3rd-Steven-Halim/dp/B00FG8MNN8) 31 | - [GeeksForGeeks](https://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/) 32 | 33 | #### Source Codes 34 | - C++ | [s0](vanilla_implementations/primeFactorization.cpp) 35 | 36 | #### Questions 37 | - [Medium Factorization](http://www.spoj.com/problems/FACTCG2/) | [Python](solutions/medium_factorization.py), [C++](https://github.com/NAU-ACM/Competitive-Programming/blob/master/SPOJ/Medium%20Factorization.cpp) 38 | 39 | ## Modular Exponentiation 40 | 41 | #### [Tutorial](http://nadide.github.io/Modular-Exponentiation/) 42 | 43 | #### Written Sources 44 | - [Topcoder](https://www.topcoder.com/thrive/articles/Primality%20Testing%20:%20Non-deterministic%20Algorithms) 45 | - [GeeksForGeeks](https://www.geeksforgeeks.org/modular-exponentiation-power-in-modular-arithmetic/) 46 | 47 | #### Video Sources 48 | - [Youtube - mycodeschool](https://www.youtube.com/watch?v=nO7_qu2kd1Q) 49 | 50 | #### Source Codes 51 | - C++ | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/math_modExponent.cpp), [s1](vanilla_implementations/modularExponentiation.cpp) 52 | 53 | #### Questions 54 | - [Power of Large Numbers](https://www.hackerrank.com/challenges/power-of-large-numbers) | [Python](https://github.com/NAU-ACM/Competitive-Programming/blob/master/HackerRank/Practices/Math/PowerOfLargeNumbers.py) 55 | -------------------------------------------------------------------------------- /Week05/README.md: -------------------------------------------------------------------------------- 1 | # Week 5 2 | 3 | ## Stack & Queue 4 | 5 | #### Video Sources 6 | - [HackerRank - Video](https://www.youtube.com/watch?v=wjI1WNcIntg) 7 | 8 | #### Written Sources 9 | - [GeeksforGeeks - Queue](https://www.geeksforgeeks.org/queue-set-1introduction-and-array-implementation/) 10 | - [GeeksforGeeks - Stack](https://www.geeksforgeeks.org/stack-data-structure-introduction-program/) 11 | 12 | #### Questions 13 | - [Redundant Brackets](https://careercup.com/question?id=5769760746766336) | [Java](https://github.com/rajat123456/Stacks-And-Queues/blob/master/Redundant%20Brackets%20Teaser.java) 14 | - [Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/description/) | [Python](solutions/largest_rectangle.py) 15 | - [Stock Span Problem](https://www.geeksforgeeks.org/the-stock-span-problem/) | [Python](solutions/stock_span_problem.py) 16 | 17 | 18 | ## Breadth First Search 19 | 20 | #### Video Sources 21 | - [Youtube - Michael Sambol](https://www.youtube.com/watch?v=HZ5YTanv5QE) 22 | - [Youtube - Abhinav Tripathi](https://www.youtube.com/watch?v=bIA8HEEUxZI) 23 | 24 | #### Written Sources 25 | - [KhanAcademy](https://www.khanacademy.org/computing/computer-science/algorithms/breadth-first-search/a/the-breadth-first-search-algorithm) 26 | - [GeeksforGeeks](https://www.geeksforgeeks.org/breadth-first-traversal-for-a-graph/) 27 | - [HackerEarth](https://www.hackerearth.com/practice/algorithms/graphs/breadth-first-search/tutorial/) 28 | - [Topcoder](https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-2/#breadth) 29 | 30 | #### Source Codes 31 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Graph/bfs.cpp), [s1](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Graph/bfs_simple.cpp) 32 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/graph_BFS.c) 33 | - Python | [s0](vanilla_implementations/bfs.py) 34 | 35 | #### Questions 36 | - [BFS Shortest Reach](https://www.hackerrank.com/challenges/bfsshortreach) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Graph%20Theory/Breadth%20First%20Search%20_%20Shortest%20Reach.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/graph/breadthFirstSearchShortestPath.c) 37 | - [Hike](http://www.spoj.com/problems/HIKE/) | [Python](solutions/hike.py) 38 | - [Herding](http://www.spoj.com/problems/HERDING/) | [Python](solutions/herding.py), [C++](solution/herding.cpp) 39 | 40 | 41 | 42 | ## Depth First Search 43 | 44 | #### Video Sources 45 | - [Youtube - Michael Sambol](https://www.youtube.com/watch?v=Urx87-NMm6c) 46 | - [Youtube - Michael Seery](https://www.youtube.com/watch?v=bkROCj-BTWE) 47 | 48 | #### Written Sources 49 | - [GeeksForGeeks](http://www.geeksforgeeks.org/depth-first-traversal-for-a-graph/) 50 | - [VisualAlgo](http://visualgo.net/dfsbfs) 51 | - [Topcoder](https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-2/#depth) 52 | 53 | #### Source Codes 54 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Graph/dfs.cpp) 55 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/graph_DFS.c) 56 | - Python | [s0](vanilla_implementations/dfs.py) 57 | 58 | #### Questions 59 | - [ALL iz Wel](http://www.spoj.com/problems/ALLIZWEL/) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%205/ALLIZZWELL.cpp), [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/spoj/X_allIzzWell.c) 60 | - [Prayatna](http://www.spoj.com/problems/CAM5/) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%205/Prayatna.cpp) 61 | - [Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths/) 62 | - [Count Luck](https://www.hackerrank.com/challenges/count-luck) 63 | - [Connected Cell in a Grid](https://www.hackerrank.com/challenges/connected-cell-in-a-grid) 64 | - [Graph Coloring](http://codeforces.com/problemset/problem/662/B) 65 | -------------------------------------------------------------------------------- /Week06/README.md: -------------------------------------------------------------------------------- 1 | # Week 6 2 | 3 | ## Linked List 4 | 5 | #### Video Sources 6 | - [Youtube - Hackerrank](https://www.youtube.com/watch?v=njTh_OwMljA) 7 | 8 | #### Written Sources 9 | - [GeeksForGeeks - Introduction to Linked List](https://www.geeksforgeeks.org/linked-list-set-1-introduction/) 10 | - [CS CMU](https://www.cs.cmu.edu/~adamchik/15-121/lectures/Linked%20Lists/linked%20lists.html) 11 | - [Tutorialpoint](https://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms.htm) 12 | 13 | #### Questions 14 | - [Print the Elements of a Linked List](https://www.hackerrank.com/challenges/print-the-elements-of-a-linked-list/problem) 15 | - [Delete a Node](https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list/problem) 16 | - [Merge two sorted linked lists](https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists/problem) 17 | - [Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group/description/) 18 | - [Java Solution](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/LeetCode(Reverse%20Nodes%20in%20k-Group).java) 19 | - [Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list/description/) 20 | - [Java Solution](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/LeetCode(Remove%20Duplicates%20from%20Sorted%20List).java) 21 | - [Add 1 to number represented in linked list](https://github.com/rajat123456/LinkedList-in-Java/blob/master/Add_1_to_number_represented_in_linked_list.java) 22 | - [Sort a linked list of 0s 1s and 2s](https://www.careercup.com/question?id=14578074) 23 | - [Java Solution](https://github.com/rajat123456/LinkedList-in-Java/blob/master/Sort_a_linked_list_of_0s_1s_and_2s.java) 24 | - [Check Loop in Link List](https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle/problem) 25 | - [Approach 1](https://github.com/rajat123456/LinkedList-in-Java/blob/master/CheckLoopInLinkList1.java) 26 | - [Approach 2](https://github.com/rajat123456/LinkedList-in-Java/blob/master/CheckLoopInLinkList2.java) 27 | - [Appoach 3](https://github.com/rajat123456/LinkedList-in-Java/blob/master/CheckLoopInLinkList3.java) 28 | 29 | ## Dijkstra’s Shortest Path 30 | 31 | #### Video Sources 32 | - [Youtube - Santitham Prom-on](https://www.youtube.com/watch?v=WN3Rb9wVYDY) 33 | - [Youtube - distanceedjohn](https://www.youtube.com/watch?v=8Ls1RqHCOPw) 34 | - 35 | #### Written Sources 36 | - [GeeksForGeeks](http://www.geeksforgeeks.org/greedy-algorithms-set-6-dijkstras-shortest-path-algorithm/) 37 | - [Topcoder](https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-3/#dijkstra) 38 | 39 | #### Source Codes 40 | - C++ | [s0](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Graph/dijkstra.cpp) 41 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/graph_Dijkstra.c) 42 | 43 | #### Questions 44 | - [Djikstra Shortest Reach](https://www.hackerrank.com/challenges/dijkstrashortreach) | [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/graph/dijkstraShortestPath.c), [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Graph%20Theory/Dijkstra_Shortest%20Reach%202.cpp) 45 | - [Travel cost](http://www.spoj.com/problems/TRVCOST/) | [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%205/TRVCOST%20-%20Travelling%20cost.cpp) 46 | - [Small Quiz by GeeksForGeeks](http://quiz.geeksforgeeks.org/algorithms/graph-shortest-paths/) 47 | 48 | 49 | 50 | ## Prim's Minimum Spanning Tree (MST) 51 | 52 | #### Written Sources 53 | - [GeeksForGeeks](http://www.geeksforgeeks.org/greedy-algorithms-set-2-kruskals-minimum-spanning-tree-mst/) 54 | 55 | #### Source Codes 56 | - C++, Prim's Algo | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/graph_primMST2.cpp) 57 | - C++, Kruskal's Algo | [s0](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Graph/MST%20-%20Kruskal's%20Algo.cpp) 58 | 59 | #### Questions 60 | - [Prim's (MST) : Special Subtree](https://www.hackerrank.com/contests/master/challenges/primsmstsub?h_r=internal-search) 61 | 62 | 63 | ## Floyd Warshall (All Pairs Shortest Path) 64 | 65 | #### Video Sources 66 | - [Youtube - Romesh Malinga Perera](https://www.youtube.com/watch?v=9QV6QpyhN0o) 67 | - [Youtube - Quinston Pimenta](https://www.youtube.com/watch?v=K6rI0umX-28) 68 | 69 | #### Written Sources 70 | - [GeeksForGeeks](http://www.geeksforgeeks.org/dynamic-programming-set-16-floyd-warshall-algorithm/) 71 | - [Topcoder](https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-3/#floydWarshall) 72 | 73 | #### Source Codes 74 | - C++ | [s0](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Dynamic/Floyd%20Warshall.cpp) 75 | - C | [s0](https://github.com/nadide/ACM-ICPC/blob/master/codes/graph_FloydWarshall.c) 76 | 77 | #### Questions 78 | - [Floyd City of Lights](https://www.hackerrank.com/challenges/floyd-city-of-blinding-lights?h_r=internal-search) | [C](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/graph/floydCityOfBlindingLights.c), [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Algorithms/Graph%20Theory/Floyd%20City%20of%20Blinding%20Lights.cpp) 79 | - [Arbitrage](https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=40) 80 | - [API-Maelstrom](https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=364) 81 | 82 | ## Extra - Cycle Detection (Union Find) 83 | 84 | #### Written Sources 85 | - [GeeksForGeeks - Part 1, Implementing](http://www.geeksforgeeks.org/union-find/) 86 | - [GeeksForGeeks - Part 2, Improving](http://www.geeksforgeeks.org/union-find-algorithm-set-2-union-by-rank/) 87 | 88 | #### Source Codes 89 | - C++ | [s0](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Graph/Cycle%20Detection%20-%20Union%20Find%20(Improved).cpp) 90 | -------------------------------------------------------------------------------- /Week09/README.md: -------------------------------------------------------------------------------- 1 | # Week 9 2 | 3 | 4 | ## Trees 5 | 6 | #### [Tutorial]() 7 | 8 | #### Other Study Sources 9 | - [Youtube - mycodeschool](https://www.youtube.com/watch?v=qH6yxkw0u78) 10 | - [GeeksforGeeks](http://www.geeksforgeeks.org/applications-of-tree-data-structure/) 11 | - [Tutorialspoint](http://www.tutorialspoint.com/data_structures_algorithms/tree_data_structure.htm) 12 | - [HackerRank](https://www.hackerrank.com/topics/lowest-common-ancestor) 13 | 14 | #### Source Codes 15 | - Bedir - [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Data%20Structures/DS-Tree.cpp) 16 | - Nadide - [C++](https://github.com/nadide/ACM-ICPC/blob/master/codes/tree.cpp) 17 | 18 | #### Questions 19 | - [Tree: Preorder Traversal](https://www.hackerrank.com/challenges/tree-preorder-traversal) 20 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Tree_Preorder%20Traversal.cpp) 21 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/trees_preorderTraversal.cpp) 22 | - [Tree: Postorder Traversal](https://www.hackerrank.com/challenges/tree-postorder-traversal) 23 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Tree_Postorder%20Traversal.cpp) 24 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/trees_postorderTraversal.cpp) 25 | - [Tree: Inorder Traversal](https://www.hackerrank.com/challenges/tree-inorder-traversal) 26 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Tree_inOrder%20Traversal.cpp) 27 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/trees_inorderTraversal.cpp) 28 | - [Tree: Height of a Binary Tree](https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree) 29 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Tree_Height%20of%20a%20Binary%20Tree.cpp) 30 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/trees_heightOfBinaryTree.cpp) 31 | - [Tree: Top View](https://www.hackerrank.com/challenges/tree-top-view) 32 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Tree_Top%20View.cpp) 33 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/tress_topView.cpp) 34 | - [Tree: Level Order Traversal](https://www.hackerrank.com/challenges/tree-level-order-traversal) 35 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Tree_Level%20Order%20Traversal.cpp) 36 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/trees_levelorderTraversal.cpp) 37 | - [Binary Search Tree: Insertion](https://www.hackerrank.com/challenges/binary-search-tree-insertion) 38 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Binary%20Search%20Tree_Insertion.cpp) 39 | - [Nadide's Solution](https://github.com/nadide/ACM-ICPC/blob/master/problems/hackerrank/ds/trees_BST_insertion.cpp) 40 | - [Binary Search Tree: Lowest Common Ancestor](https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor) 41 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/HackerRank/Data%20Structures/Trees/Binary%20Search%20Tree_Lowest%20Common%20Ancestor.cpp) 42 | - [Tree: Huffman Decoding](https://www.hackerrank.com/challenges/tree-huffman-decoding) 43 | - [Swap Nodes (Algo)](https://www.hackerrank.com/challenges/swap-nodes-algo) 44 | - [Is This a Binary Search Tree?](https://www.hackerrank.com/challenges/is-binary-search-tree) 45 | - [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/description/) 46 | - [Java Solution](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/LeetCode(Balanced%20Binary%20Tree).java) 47 | 48 | 49 | ## Segment Trees (DS) 50 | 51 | #### [Tutorial]() 52 | 53 | #### Other Study Sources 54 | - [HackerEarth](https://www.hackerearth.com/practice/data-structures/advanced-data-structures/segment-trees/tutorial/) 55 | #### Source Codes 56 | - [Building Segment Tree](https://github.com/rajat123456/Tree-Data-Structure-in-Java/blob/master/Building%20Segment%20Tree.java) 57 | - [Query on Segment Tree](https://github.com/rajat123456/Tree-Data-Structure-in-Java/blob/master/Query%20on%20Segment%20Tree.java) 58 | - [Update on Segment Tree](https://github.com/rajat123456/Tree-Data-Structure-in-Java/blob/master/Update%20on%20Segment%20Tree.java) 59 | #### Questions 60 | 61 | 62 | 63 | ## Range Minimum Query (RMQ) 64 | 65 | #### [Tutorial]() 66 | 67 | #### Other Study Sources 68 | - [GeeksforGeeks](http://www.geeksforgeeks.org/segment-tree-set-1-range-minimum-query/) 69 | - [Topcoder](https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/) 70 | - [Wikipedia](https://en.wikipedia.org/wiki/Range_minimum_query) 71 | 72 | #### Source Codes 73 | - Bedir - [C++](https://github.com/BedirT/Algorithms_and_DS/blob/master/Algorithms/Graph/RMQ.cpp) 74 | - Nadide - [C++](https://github.com/nadide/ACM-ICPC/blob/master/codes/tree_RMQ.cpp) 75 | 76 | #### Questions 77 | - [RMQSQ](http://www.spoj.com/problems/RMQSQ/) 78 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%207/RMQSQ.cpp) 79 | - [Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query-immutable/) 80 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%207/Range%20Sum%20Query%20-%20Immutable.cpp) 81 | - [Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable/) 82 | - [Bedir's Solution](https://github.com/BedirT/AlgorithmsL/blob/master/Problems/Curriculum%20Q's/Week%207/Range%20Sum%20Query%20-%20Mutable.cpp) 83 | - [Mstick](https://discuss.codechef.com/questions/9722/mstick-editorial) 84 | - [Minimum in SubArray](https://www.hackerearth.com/practice/data-structures/advanced-data-structures/segment-trees/practice-problems/algorithm/range-minimum-query/) 85 | - [Java Solution](https://github.com/rajat123456/General-Competitive-Programming-Questions/blob/master/HackerEarth(Minimum%20in%20SubArray).java) 86 | 87 | 88 | 89 | ## Lowest Common Ancestor (LCA) 90 | 91 | #### [Tutorial]() 92 | 93 | #### Other Study Sources 94 | - [GeeksforGeeks](http://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/) 95 | - [Topcoder](https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/) 96 | 97 | #### Source Codes 98 | - Bedir - [C++](https://github.com/BedirT/AlgorithmsL/blob/master/Algorithms/Graph/Lowest%20Common%20Ancestor.cpp) 99 | - Nadide - [C++](https://github.com/nadide/ACM-ICPC/blob/master/codes/tree_LCA.cpp) 100 | 101 | #### Questions 102 | - [Query on a Tree II](http://www.spoj.com/problems/QTREE2/) 103 | - [Housewife Wind](http://poj.org/problem?id=2763) 104 | - [Distance Queries](http://poj.org/problem?id=1986) 105 | - [Distance in the Tree](http://acm.timus.ru/problem.aspx?space=1&num=1471) 106 | - [Tree 2](http://acm.timus.ru/problem.aspx?space=1&num=1752) 107 | - [Turning Turtles](http://acm.timus.ru/problem.aspx?space=1&num=1699) 108 | - [LCA](http://www.spoj.com/problems/LCA/) 109 | - [Distance Query](http://www.spoj.com/problems/DISQUERY/) 110 | - [Fools and Roads](http://codeforces.com/problemset/problem/192/E) 111 | 112 | 113 | 114 | ## Topological Sorting 115 | 116 | #### [Tutorial]() 117 | 118 | #### Other Study Sources 119 | 120 | #### Source Codes 121 | 122 | #### Questions 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![ACM-ICPC](https://github.com/NAU-ACM/ACM-ICPC-Preparation/blob/master/acm_icpc_prep.jpg "ACM-ICPC") 2 | 3 | # ACM-ICPC Preparation 4 | ![](https://img.shields.io/badge/licence-MIT-green.svg) ![](https://img.shields.io/badge/Weeks%20Completed-8%2F20-orange.svg) ![](https://img.shields.io/badge/Revisions-4%2F20-red.svg) 5 | 6 | This curriculum has been developed to learn Algorithms to use in Competitive Programming, **but can also be used for:** 7 | - Practicing for Interviews 8 | - Improving Algorithmic Thinking 9 | - Practicing for College Classes 10 | 11 | **Prerequisites:** 12 | - To know at least one programming language. (_You have to be able to use the language efficiently._) 13 | 14 | The concept of this repository is to have well-structured content divided into parts that one can follow even if they are busy. Here we collected sources we find well prepared to learn the proposed topics. The curriculum has different data structures and algorithms. 15 | 16 | **Estimated time required for a week is 6-7 hours.** (To complete the curriculum in the given time) 17 | 18 | **Basic usage guide:** 19 | Using this repository depends on what the user wants to do with it. Here we are suggesting the following for people who want to slowly gain knowledge of the topics while continuing their studies etc.: 20 | 1. Check out the written or video sources provided for a given topic depending on the preference. Go over as many as needed to gain a good understanding of the topic. 21 | 2. Without checking the source code, try to replicate the algorithm or data structure on your own. 22 | 3. When stuck or when done, look at the source codes provided, and compare them with yours to see what might be your mistake. Try to fix it. 23 | 4. After you feel comfortable with the code, try to solve the given problems. 24 | 5. When you are done with solving or are stuck at some point, check given solutions and try to understand your mistake or see if a better approach exists. 25 | 26 | ## Resources 27 | 28 | Here are some of the websites/tools that we use through this curriculum: 29 | 30 | - [Leetcode](https://leetcode.com) 31 | - [Spoj](http://www.spoj.com) 32 | - [Hackerrank](https://www.hackerrank.com/domains) 33 | - [Topcoder](https://www.topcoder.com) 34 | - [Codeforces](http://codeforces.com) 35 | - [Lightoj](http://www.lightoj.com) 36 | - [ACM-Timus](http://acm.timus.ru) 37 | 38 | ## Contribution 39 | 40 | If you have anything to add, do not hesitate to offer! You can check [Code of Conduct](CODE_OF_CONDUCT.md). You can submit a PR or an issue; I will try to personally review all. 41 | 42 | ## Topics 43 | 44 | Here are the topics we currently include in the curriculum. 45 | 46 | ### Data Structures 47 | - Stacks 48 | - Queues 49 | - Priority queue 50 | - Hashmap 51 | - Linked List 52 | - Trees 53 | - Heaps 54 | - Advanced Trees 55 | - Tries 56 | - Segment trees 57 | - Fenwick tree or Binary indexed trees 58 | - RMQ 59 | - SQRT Decomposition 60 | - Disjoint Data Structure 61 | - C++ STL (optional) 62 | 63 | ### Algorithms 64 | - Number Theory 65 | - Prime Numbers (Sieve of Eratosthenes) 66 | - GCD and LCM Euclid’s Algorithm 67 | - Modular Exponentiation 68 | - Long arithmetic (Multi, Add) 69 | - Efficient Prime Factorization 70 | 71 | - Combinatorics (Probability-Combinations-Permutations-Matrix..) 72 | 73 | - Computational Geometry 74 | - Primitive Operations 75 | - Intuition 76 | - Polygon Inside, Outside 77 | - Implementing CCW 78 | - Immutable Point ADT 79 | - Convex Hull 80 | - Closest pair problem 81 | - Line intersection 82 | 83 | - Sort 84 | - QuickSort 85 | - Counting Sort 86 | - Merge Sort 87 | 88 | - Search 89 | - Binary Search 90 | - Ternary Search 91 | 92 | - Graph Theory 93 | - Depth First Search (DFS) 94 | - Breadth First Search (BFS) 95 | - Dijkstra’s Shortest Path 96 | - Minimum Spanning Tree 97 | - Ford Bellman 98 | - Floyd Warshall 99 | - LCA (Lowest Common Ancestor) 100 | - Max Flow / Min Cut 101 | 102 | - Dynamic Programming 103 | - Knapsack 104 | - Matrix chain multiplication 105 | - Coin Change 106 | - Kadane 107 | - Longest increasing Subsequence (with RMQ) 108 | 109 | - Strings 110 | - Z algorithm 111 | - Suffix Trees/Arrays 112 | - Knuth-Morris-Pratt Algorithm (KMP) 113 | - Rabin-Karp Algorithm 114 | - Hash 115 | 116 | - Bit Manipulation 117 | 118 | - Game theory 119 | - Nim game 120 | - Grundy numbers 121 | - Sprague-Grundy theorem 122 | 123 | - **Optional Advanced Algorithms** 124 | - AVL Trees 125 | - Graph Coloring 126 | - Mo's Algorithm 127 | - Palindromic Tree 128 | - Heavy Light Decomposition 129 | - Dynamic Programming by Profile 130 | - Rod Cutting 131 | - Topological Sorting 132 | - DP with Bitmask - Dynamic Programming 133 | - Diobhantine Equation - Math 134 | - Flood Fill - Graph 135 | 136 | 137 | ## Curriculum 138 | |Week|Topics|Optional Topics| 139 | | --- | --- | --- | 140 | |[**Heads Up **](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week00)|
  • Big O Notation
|| 141 | |[**1.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week01)|
  • Prime Numbers (Sieve of Eratosthenes)
  • Efficient Prime Factorization
  • Modular Exponentiation
|| 142 | |[**2.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week02)|
  • GCD and LCM Euclid’s Algorithm
  • Long arithmetic (Multi, Sum, Div, Sub)
|
  • C++ STL:Vector
  • C++ STL:Pairs
  • C++ STL:Iterators
| 143 | |[**3.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week03)|
  • QuickSort
  • Counting Sort
|
  • C++ STL:String
  • C++ STL:Set
  • C++ STL:Map
| 144 | |[**4.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week04)|
  • Merge Sort
  • Binary Search
|
  • Ternary Search
| 145 | |[**5.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week05)|
  • Queue (DS)
  • Stack (DS)
  • Breadth First Search
  • Depth First Search
|
  • C++ STL: Queue
  • C++ STL: Stack
| 146 | |[**6.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week06)|
  • Linked List (DS)
  • Dijkstra’s Shortest Path
  • Minimum Spanning Tree (MST)
  • Floyd Warshall
|
  • Cycle Detection (Union Find)
| 147 | |[**7.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week07)|
  • Knapsack
  • Coin Change
  • Kadane
|| 148 | |[**8.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week08)|**Questions from previous topics**|| 149 | |[**9.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week09)|
  • Trees (DS)
  • Segment Trees (DS)
  • Range Minimum Query (RMQ)
  • Lowest Common Ancestor (LCA)
|
  • Topological Sorting
| 150 | |[**10.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week10)|
  • Ford Bellman
  • Max Flow / Min Cut
  • Longest increasing Subsequence (with RMQ)
|
  • Heavy Light Decomposition
| 151 | |[**11.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week11)|
  • Primitive Operations
    • Intuition
    • Polygon Inside, Outside
    • Implementing CCW
    • Immutable Point ADT
  • Convex Hull
  • Closest pair problem
  • Line intersection
|| 152 | |[**12.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week12)|
  • Tries (DS)
  • Suffix Trees/Arrays (DS)
  • Knuth-Morris-Pratt Algorithm (KMP)
  • Rabin-Karp Algorithm
|| 153 | |[**13.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week13)|
  • Heaps (DS)
  • Priority queue (DS)
  • Combinatorics
|| 154 | |[**14.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week14)|
  • Z algorithm
  • Hash
  • Disjoint Data Structure (DS)
|| 155 | |[**15.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week15)|
  • Matrix chain multiplication
  • SQRT Decomposition (DS)
|
  • Mo's Algorithm
  • Rod Cutting
| 156 | |[**16.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week16)|**Questions from previous topics**|| 157 | |[**17.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week17)|
  • Nim game
  • Grundy numbers
|| 158 | |[**18.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week18)|
  • Sprague-Grundy theorem
  • Fenwick tree or Binary indexed trees (DS)
|| 159 | |[**19.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week19)|
  • Bit Manipulation
|
  • Palindromic Tree
  • AVL Trees
| 160 | |[**20.Week**](https://github.com/NAU-ACM/ACM-ICPC-Preparation/tree/master/Week20)|
  • Heavy Light Decomposition
  • Dynamic Programming by Profile
|
  • Graph Coloring
| 161 | 162 | ### [Contributers](https://github.com/NAU-ACM/ACM-ICPC-Preparation/graphs/contributors) 163 | --------------------------------------------------------------------------------