Longest Mod Path – HackerRank Solution Java , Python 3, Python 2 , C , C++, Best and Optimal Solutions , All you need.
Solutions of Algorithms Data Structures Hard HackerRank:
Here are all the Solutions of Hard , Advanced , Expert Algorithms of Data Structure of Hacker Rank , Leave a comment for similar posts
C++ replace HackerRank Solution
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }
struct UnionFind {
vector<int> data;
void init(int n) { data.assign(n, -1); }
bool unionSet(int x, int y) {
x = root(x); y = root(y);
if(x != y) {
if(data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
vector<int> t_parent;
vi t_ord;
void tree_getorder(const vector<vi> &g, int root) {
int n = g.size();
t_parent.assign(n, -1);
t_ord.clear();
vector<int> stk; stk.push_back(root);
while(!stk.empty()) {
int i = stk.back(); stk.pop_back();
t_ord.push_back(i);
for(int j = (int)g[i].size() - 1; j >= 0; j --) {
int c = g[i][j];
if(t_parent[c] == -1 && c != root)
stk.push_back(c);
else
t_parent[i] = c;
}
}
}
template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
int main() {
int N;
while(~scanf("%d", &N)) {
UnionFind uf; uf.init(N);
vector<vi> tree(N);
map<pii, int> weight;
pair<pii,int> addedge;
rep(i, N) {
int a; int b; int x;
scanf("%d%d%d", &a, &b, &x), -- a, -- b;
if(uf.unionSet(a, b)) {
tree[a].push_back(b);
tree[b].push_back(a);
weight[make_pair(a, b)] = x;
weight[make_pair(b, a)] = -x;
} else {
addedge = make_pair(make_pair(a, b), x);;
}
}
tree_getorder(tree, 0);
vector<ll> sum(N, 0);
for(int ix = 1; ix < (int)t_ord.size(); ++ ix) {
int i = t_ord[ix], p = t_parent[i];
sum[i] = sum[p] + weight[make_pair(i, p)];
}
auto getw = [&](int a, int b) -> ll {
return sum[a] - sum[b];
};
ll cyclew;
{
int a, b;
tie(a, b) = addedge.first;
cyclew = addedge.second + getw(b, a);
}
int Q;
scanf("%d", &Q);
rep(ii, Q) {
int S; int E; int M;
scanf("%d%d%d", &S, &E, &M), -- S, -- E;
int a = cyclew % M;
int b = getw(S, E) % M;
if(a < 0) a += M;
if(b < 0) b += M;
int g = gcd(a, M);
int ans = M - g + b % g;
printf("%d\n", ans);
}
}
return 0;
}
Java rep HackerRank Solution
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Egor Kulikov (egor@egork.net)
*/
public class Solution {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
LongestModPath solver = new LongestModPath();
solver.solve(1, in, out);
out.close();
}
static class LongestModPath {
public void solve(int testNumber, InputReader in, OutputWriter out) {
int n = in.readInt();
int[] a = new int[n];
int[] b = new int[n];
int[] x = new int[n];
IOUtils.readIntArrays(in, a, b, x);
MiscUtils.decreaseByOne(a, b);
Graph graph = BidirectionalGraph.createGraph(n, a, b);
IntList cycle = dfs(graph, 0, -1, new boolean[n]);
long cycleCost = 0;
for (int i : cycle) {
if ((i & 1) == 0) {
cycleCost += x[i >> 1];
} else {
cycleCost -= x[i >> 1];
}
}
cycleCost = Math.abs(cycleCost);
long[] cost = new long[n];
dfs(graph, graph.source(cycle.get(0)), new boolean[n], cost, x, 0);
int q = in.readInt();
for (int i = 0; i < q; i++) {
int s = in.readInt() - 1;
int e = in.readInt() - 1;
long m = in.readInt();
long mm = m;
m = IntegerUtils.gcd(m, cycleCost);
long answer = (cost[e] - cost[s]) % m;
if (answer < 0) {
answer += m;
}
answer += mm - m;
out.printLine(answer);
}
}
private void dfs(Graph graph, int vertex, boolean[] visited, long[] cost, int[] x, long current) {
if (visited[vertex]) {
return;
}
visited[vertex] = true;
cost[vertex] = current;
for (int i = graph.firstOutbound(vertex); i != -1; i = graph.nextOutbound(i)) {
int next = graph.destination(i);
dfs(graph, next, visited, cost, x, current + ((i & 1) == 0 ? x[i >> 1] : -x[i >> 1]));
}
}
private IntList dfs(Graph graph, int vertex, int edge, boolean[] visited) {
visited[vertex] = true;
for (int i = graph.firstOutbound(vertex); i != -1; i = graph.nextOutbound(i)) {
if ((i ^ 1) == edge) {
continue;
}
int next = graph.destination(i);
if (visited[next]) {
IntList result = new IntArrayList();
result.add(i);
return result;
}
IntList result = dfs(graph, next, i, visited);
if (result != null) {
if (graph.destination(result.first()) != graph.source(result.last())) {
result.add(i);
}
return result;
}
}
return null;
}
}
static class Graph {
public static final int REMOVED_BIT = 0;
protected int vertexCount;
protected int edgeCount;
private int[] firstOutbound;
private int[] firstInbound;
private Edge[] edges;
private int[] nextInbound;
private int[] nextOutbound;
private int[] from;
private int[] to;
private long[] weight;
public long[] capacity;
private int[] reverseEdge;
private int[] flags;
public Graph(int vertexCount) {
this(vertexCount, vertexCount);
}
public Graph(int vertexCount, int edgeCapacity) {
this.vertexCount = vertexCount;
firstOutbound = new int[vertexCount];
Arrays.fill(firstOutbound, -1);
from = new int[edgeCapacity];
to = new int[edgeCapacity];
nextOutbound = new int[edgeCapacity];
flags = new int[edgeCapacity];
}
public int addEdge(int fromID, int toID, long weight, long capacity, int reverseEdge) {
ensureEdgeCapacity(edgeCount + 1);
if (firstOutbound[fromID] != -1) {
nextOutbound[edgeCount] = firstOutbound[fromID];
} else {
nextOutbound[edgeCount] = -1;
}
firstOutbound[fromID] = edgeCount;
if (firstInbound != null) {
if (firstInbound[toID] != -1) {
nextInbound[edgeCount] = firstInbound[toID];
} else {
nextInbound[edgeCount] = -1;
}
firstInbound[toID] = edgeCount;
}
this.from[edgeCount] = fromID;
this.to[edgeCount] = toID;
if (capacity != 0) {
if (this.capacity == null) {
this.capacity = new long[from.length];
}
this.capacity[edgeCount] = capacity;
}
if (weight != 0) {
if (this.weight == null) {
this.weight = new long[from.length];
}
this.weight[edgeCount] = weight;
}
if (reverseEdge != -1) {
if (this.reverseEdge == null) {
this.reverseEdge = new int[from.length];
Arrays.fill(this.reverseEdge, 0, edgeCount, -1);
}
this.reverseEdge[edgeCount] = reverseEdge;
}
if (edges != null) {
edges[edgeCount] = createEdge(edgeCount);
}
return edgeCount++;
}
protected final GraphEdge createEdge(int id) {
return new GraphEdge(id);
}
public final int addFlowWeightedEdge(int from, int to, long weight, long capacity) {
if (capacity == 0) {
return addEdge(from, to, weight, 0, -1);
} else {
int lastEdgeCount = edgeCount;
addEdge(to, from, -weight, 0, lastEdgeCount + entriesPerEdge());
return addEdge(from, to, weight, capacity, lastEdgeCount);
}
}
protected int entriesPerEdge() {
return 1;
}
public final int addWeightedEdge(int from, int to, long weight) {
return addFlowWeightedEdge(from, to, weight, 0);
}
public final int addSimpleEdge(int from, int to) {
return addWeightedEdge(from, to, 0);
}
protected final int edgeCapacity() {
return from.length;
}
public final int firstOutbound(int vertex) {
int id = firstOutbound[vertex];
while (id != -1 && isRemoved(id)) {
id = nextOutbound[id];
}
return id;
}
public final int nextOutbound(int id) {
id = nextOutbound[id];
while (id != -1 && isRemoved(id)) {
id = nextOutbound[id];
}
return id;
}
public final int source(int id) {
return from[id];
}
public final int destination(int id) {
return to[id];
}
public final boolean flag(int id, int bit) {
return (flags[id] >> bit & 1) != 0;
}
public final boolean isRemoved(int id) {
return flag(id, REMOVED_BIT);
}
protected void ensureEdgeCapacity(int size) {
if (from.length < size) {
int newSize = Math.max(size, 2 * from.length);
if (edges != null) {
edges = resize(edges, newSize);
}
from = resize(from, newSize);
to = resize(to, newSize);
nextOutbound = resize(nextOutbound, newSize);
if (nextInbound != null) {
nextInbound = resize(nextInbound, newSize);
}
if (weight != null) {
weight = resize(weight, newSize);
}
if (capacity != null) {
capacity = resize(capacity, newSize);
}
if (reverseEdge != null) {
reverseEdge = resize(reverseEdge, newSize);
}
flags = resize(flags, newSize);
}
}
protected final int[] resize(int[] array, int size) {
int[] newArray = new int[size];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
}
private long[] resize(long[] array, int size) {
long[] newArray = new long[size];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
}
private Edge[] resize(Edge[] array, int size) {
Edge[] newArray = new Edge[size];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
}
protected class GraphEdge implements Edge {
protected int id;
protected GraphEdge(int id) {
this.id = id;
}
}
}
static class BidirectionalGraph extends Graph {
public int[] transposedEdge;
public BidirectionalGraph(int vertexCount) {
this(vertexCount, vertexCount);
}
public BidirectionalGraph(int vertexCount, int edgeCapacity) {
super(vertexCount, 2 * edgeCapacity);
transposedEdge = new int[2 * edgeCapacity];
}
public static BidirectionalGraph createGraph(int vertexCount, int[] from, int[] to) {
BidirectionalGraph graph = new BidirectionalGraph(vertexCount, from.length);
for (int i = 0; i < from.length; i++) {
graph.addSimpleEdge(from[i], to[i]);
}
return graph;
}
public int addEdge(int fromID, int toID, long weight, long capacity, int reverseEdge) {
int lastEdgeCount = edgeCount;
super.addEdge(fromID, toID, weight, capacity, reverseEdge);
super.addEdge(toID, fromID, weight, capacity, reverseEdge == -1 ? -1 : reverseEdge + 1);
this.transposedEdge[lastEdgeCount] = lastEdgeCount + 1;
this.transposedEdge[lastEdgeCount + 1] = lastEdgeCount;
return lastEdgeCount;
}
protected int entriesPerEdge() {
return 2;
}
protected void ensureEdgeCapacity(int size) {
if (size > edgeCapacity()) {
super.ensureEdgeCapacity(size);
transposedEdge = resize(transposedEdge, edgeCapacity());
}
}
}
static class OutputWriter {
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void close() {
writer.close();
}
public void printLine(long i) {
writer.println(i);
}
}
static interface Edge {
}
static abstract class IntAbstractStream implements IntStream {
public String toString() {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
if (first) {
first = false;
} else {
builder.append(' ');
}
builder.append(it.value());
}
return builder.toString();
}
public boolean equals(Object o) {
if (!(o instanceof IntStream)) {
return false;
}
IntStream c = (IntStream) o;
IntIterator it = intIterator();
IntIterator jt = c.intIterator();
while (it.isValid() && jt.isValid()) {
if (it.value() != jt.value()) {
return false;
}
it.advance();
jt.advance();
}
return !it.isValid() && !jt.isValid();
}
public int hashCode() {
int result = 0;
for (IntIterator it = intIterator(); it.isValid(); it.advance()) {
result *= 31;
result += it.value();
}
return result;
}
}
static class IntegerUtils {
public static long gcd(long a, long b) {
a = Math.abs(a);
b = Math.abs(b);
while (b != 0) {
long temp = a % b;
a = b;
b = temp;
}
return a;
}
}
static interface IntIterator {
public int value() throws NoSuchElementException;
public boolean advance();
public boolean isValid();
}
static class IOUtils {
public static void readIntArrays(InputReader in, int[]... arrays) {
for (int i = 0; i < arrays[0].length; i++) {
for (int j = 0; j < arrays.length; j++) {
arrays[j][i] = in.readInt();
}
}
}
}
static interface IntList extends IntReversableCollection {
public abstract int get(int index);
public abstract void addAt(int index, int value);
public abstract void removeAt(int index);
default public int first() {
return get(0);
}
default public int last() {
return get(size() - 1);
}
default public IntIterator intIterator() {
return new IntIterator() {
private int at;
private boolean removed;
public int value() {
if (removed) {
throw new IllegalStateException();
}
return get(at);
}
public boolean advance() {
at++;
removed = false;
return isValid();
}
public boolean isValid() {
return !removed && at < size();
}
public void remove() {
removeAt(at);
at--;
removed = true;
}
};
}
default public void add(int value) {
addAt(size(), value);
}
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private InputReader.SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1) {
throw new InputMismatchException();
}
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0) {
return -1;
}
}
return buf[curChar++];
}
public int readInt() {
int c = read();
while (isSpaceChar(c)) {
c = read();
}
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9') {
throw new InputMismatchException();
}
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public boolean isSpaceChar(int c) {
if (filter != null) {
return filter.isSpaceChar(c);
}
return isWhitespace(c);
}
public static boolean isWhitespace(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
static class IntArrayList extends IntAbstractStream implements IntList {
private int size;
private int[] data;
public IntArrayList() {
this(3);
}
public IntArrayList(int capacity) {
data = new int[capacity];
}
public IntArrayList(IntCollection c) {
this(c.size());
addAll(c);
}
public IntArrayList(IntStream c) {
this();
if (c instanceof IntCollection) {
ensureCapacity(((IntCollection) c).size());
}
addAll(c);
}
public IntArrayList(IntArrayList c) {
size = c.size();
data = c.data.clone();
}
public IntArrayList(int[] arr) {
size = arr.length;
data = arr.clone();
}
public int size() {
return size;
}
public int get(int at) {
if (at >= size) {
throw new IndexOutOfBoundsException("at = " + at + ", size = " + size);
}
return data[at];
}
private void ensureCapacity(int capacity) {
if (data.length >= capacity) {
return;
}
capacity = Math.max(2 * data.length, capacity);
data = Arrays.copyOf(data, capacity);
}
public void addAt(int index, int value) {
ensureCapacity(size + 1);
if (index > size || index < 0) {
throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
}
if (index != size) {
System.arraycopy(data, index, data, index + 1, size - index);
}
data[index] = value;
size++;
}
public void removeAt(int index) {
if (index >= size || index < 0) {
throw new IndexOutOfBoundsException("at = " + index + ", size = " + size);
}
if (index != size - 1) {
System.arraycopy(data, index + 1, data, index, size - index - 1);
}
size--;
}
}
static interface IntReversableCollection extends IntCollection {
}
static interface IntStream extends Iterable<Integer>, Comparable<IntStream> {
public IntIterator intIterator();
default public Iterator<Integer> iterator() {
return new Iterator<Integer>() {
private IntIterator it = intIterator();
public boolean hasNext() {
return it.isValid();
}
public Integer next() {
int result = it.value();
it.advance();
return result;
}
};
}
default public int compareTo(IntStream c) {
IntIterator it = intIterator();
IntIterator jt = c.intIterator();
while (it.isValid() && jt.isValid()) {
int i = it.value();
int j = jt.value();
if (i < j) {
return -1;
} else if (i > j) {
return 1;
}
it.advance();
jt.advance();
}
if (it.isValid()) {
return 1;
}
if (jt.isValid()) {
return -1;
}
return 0;
}
}
static interface IntCollection extends IntStream {
public int size();
default public void add(int value) {
throw new UnsupportedOperationException();
}
default public IntCollection addAll(IntStream values) {
for (IntIterator it = values.intIterator(); it.isValid(); it.advance()) {
add(it.value());
}
return this;
}
}
static class MiscUtils {
public static void decreaseByOne(int[]... arrays) {
for (int[] array : arrays) {
for (int i = 0; i < array.length; i++) {
array[i]--;
}
}
}
}
}
Python 3 rep HackerRank Solution
from fractions import gcd
n=int(input())
adjlst = [[] for i in range(n)]
for j in range(0,n):
arr=list(map(int,input().split()))
a=arr[0]-1
b=arr[1]-1
c=arr[2]
adjlst[a].append((b,c))
adjlst[b].append((a,-c))
dist = [None]*n
parents = [set() for i in range(n)]
dist[0] = 0
stack = [0]
while stack:
i = stack.pop()
for j, c in adjlst[i]:
if j in parents[i]: continue
dist1 = dist[i] + c
parents[j].add(i)
if dist[j] is None:
dist[j] = dist1
stack.append(j)
else:
cycle = abs(dist[j] - dist1)
q=int(input())
for j in range(0,q):
arr1=list(map(int,input().split()))
s=arr1[0]
e=arr1[1]
m=arr1[2]
a = gcd(cycle, m)
print (m - a + (dist[e-1] - dist[s-1]) % a)
Python 2 rep HackerRank Solution
n = input()
adj = [[] for i in xrange(n)]
for i in xrange(n):
a, b, c = map(int, raw_input().strip().split())
a -= 1; b -= 1
adj[a].append((b, c))
adj[b].append((a, -c))
dist = [None]*n
parents = [set() for i in xrange(n)] # set because of special case: cycle of length 2
dist[0] = 0
stack = [0]
while stack:
i = stack.pop()
for j, c in adj[i]:
if j in parents[i]: continue
ndist = dist[i] + c
parents[j].add(i)
if dist[j] is None:
dist[j] = ndist
stack.append(j)
else:
cycle = abs(dist[j] - ndist)
from fractions import gcd
for qq in xrange(input()):
s, e, m = map(int, raw_input().strip().split())
a = gcd(cycle, m)
print m - a + (dist[e-1] - dist[s-1]) % a
C rep HackerRank Solution
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define HASH_SIZE 123455
#define INF 1000000007
typedef struct _node{
int x;
int y;
int w;
struct _node *next;
} node;
typedef struct _lnode{
int x;
int w;
struct _lnode *next;
} lnode;
void insert_edge(int x,int y,int w);
void dfs0(int x,int y);
void dfs1(int x);
void get_loop(int x,int y);
long long CC(long long n, long long d);
void insert(int x,int y,int w);
int search(int x,int y);
lnode *table[100000]={0};
node *hash[HASH_SIZE]={0};
int loop[100000]={0},trace[100000]={0},point[100000],first_point,breakp=0,cycle_found=0;
long long cycle=0,dis[100000]={0},cycle_save;
int main(){
int N,a,b,x,S,E,M,Q,MOD,DIS,GCD,ans,i;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d%d%d",&a,&b,&x);
insert_edge(a-1,b-1,x);
if(a>b)
Q=search(b-1,a-1);
else
Q=search(a-1,b-1);
if(Q==INF)
if(a>b)
insert(b-1,a-1,-x);
else
insert(a-1,b-1,x);
else{
if(a>b)
cycle=x+Q;
else
cycle=x-Q;
cycle_found=1;
cycle_save=cycle;
}
}
dfs0(0,-1);
if(!loop[0])
point[0]=first_point;
memset(trace,0,sizeof(trace));
dfs1(0);
if(cycle_found)
cycle=cycle_save;
scanf("%d",&Q);
while(Q--){
scanf("%d%d%d",&S,&E,&M);
MOD=(cycle%M+M)%M;
DIS=((dis[E-1]-dis[S-1])%M+M)%M;
if(!MOD)
ans=DIS;
else{
GCD=CC(MOD,M);
ans=(M-1-DIS)/GCD*GCD+DIS;
}
printf("%d\n",ans);
}
return 0;
}
void insert_edge(int x,int y,int w){
lnode *t=malloc(sizeof(lnode));
t->x=y;
t->w=w;
t->next=table[x];
table[x]=t;
t=malloc(sizeof(lnode));
t->x=x;
t->w=-w;
t->next=table[y];
table[y]=t;
return;
}
void dfs0(int x,int y){
lnode *p;
trace[x]=1;
for(p=table[x];p;p=p->next)
if(!trace[p->x]){
dis[p->x]=dis[x]+p->w;
dfs0(p->x,x);
}
else if(p->x!=y && !loop[p->x]){
first_point=p->x;
get_loop(p->x,-1);
cycle+=p->w;
}
return;
}
void dfs1(int x){
lnode *p;
trace[x]=1;
if(loop[x])
point[x]=x;
for(p=table[x];p;p=p->next)
if(!trace[p->x]){
if(!loop[p->x])
point[p->x]=point[x];
dfs1(p->x);
}
return;
}
void get_loop(int x,int y){
lnode *p;
loop[x]=1;
for(p=table[x];p && !breakp;p=p->next)
if(trace[p->x] && !loop[p->x]){
cycle+=p->w;
get_loop(p->x,x);
if(!breakp)
cycle-=p->w;
}
else if(p->x==first_point && p->x!=y){
breakp=1;
break;
}
return;
}
long long CC(long long n, long long d){
while( 1 )
{
n = n % d;
if( n == 0 )
return d;
d = d % n;
if( d == 0 )
return n;
}
}
void insert(int x,int y,int w){
int bucket=(x*100000LL+y)%HASH_SIZE;
node *t;
t=(node*)malloc(sizeof(node));
t->x=x;
t->y=y;
t->w=w;
t->next=hash[bucket];
hash[bucket]=t;
return;
}
int search(int x,int y){
int bucket=(x*100000LL+y)%HASH_SIZE;
node *t=hash[bucket];
while(t){
if(t->x==x && t->y==y)
return t->w;
t=t->next;
}
return INF;
}
Warmup
Implementation
Strings
Sorting
Search
Graph Theory
Greedy
Dynamic Programming
Constructive Algorithms
Bit Manipulation
Recursion
Game Theory
NP Complete
Debugging
Leave a comment below