You might have experienced runtime failure because of computation speed limitation in Coding test problem, as just like me. This can certainly be attributed to the lack of your knowledge of the relationship between "given computation cacpability" and "time limitation".
You must learn the concenpts below before you actully start solving problems [1]:
- basics (brute-force, sorting, data structures)
- Dynamic programming
- Greedy Algorithm
- Math (Prime Number, GCD, Log)
- Backtracking
- BFS, DFS
- Simulation
- Binary Search
- Two Pointers
- Single Source Shortest Path Problem
- Union Find
- Minimum Spanning Tree
public static int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
public static int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}