This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
#include "stdlib.h" | |
#include "limits.h" | |
#include "math.h" | |
#include "string.h" | |
#include "stdint.h" | |
#include "stack" | |
#include "queue" | |
#include "vector" | |
#include "set" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Kruskal using Union_Find | |
#include "stdio.h" | |
#include "string.h" | |
#include "vector" | |
#include "algorithm" | |
using namespace std; | |
#define pii pair<int, int> | |
#define pip pair<int, pii> | |
#define F first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
#include "stdlib.h" | |
#include "string.h" | |
#include "algorithm" | |
using namespace std; | |
// Begins Suffix Arrays implementation | |
// O(n log n) - Manber and Myers algorithm | |
// Refer to "Suffix arrays: A new method for on-line txting searches", | |
// by Udi Manber and Gene Myers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Point sum query, Range update Binary Indexed tree | |
//Author: Chandan Mittal | |
#include<stdio.h> | |
int BIT[10010], a[10010], n; | |
int query(int k) | |
{ | |
int s =0; | |
while(k > 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Point Update, Range Sum Query Binary Indexed Tree | |
//Author: Chandan Mittal | |
#include<stdio.h> | |
int BIT[100010], n, a[100010]; | |
void update(int x, int v) | |
{ | |
while(x <= n) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string> | |
#include <algorithm> | |
using namespace std; | |
struct node | |
{ | |
int prefix_count; | |
bool isEnd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
void computeLPSarray(char *pat, int M, int *lps) | |
{ | |
int len = 0; //lenght of previous longest prefix suffix | |
int i ; | |
lps[0] = 0 ; //lps[0] is always 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Algo: Pollar Rho | |
Task: Prime Factorization of an Integer | |
Author: Chandan Mittal | |
*/ | |
#include "stdio.h" | |
#include "stdlib.h" | |
#include "string.h" | |
#include "time.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Segment Tree implementation for Range Maximum Query | |
Author: Chandan Mittal | |
*/ | |
#include "stdio.h" | |
#include "stdlib.h" | |
#include "limits.h" | |
#include "math.h" | |
#include "string.h" | |
#define min(a,b) (a)<(b)?(a):(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
#include "string.h" | |
#define MAX 1000 | |
class stack | |
{ | |
int arr[MAX]; | |
int idx; | |
public: | |
stack() |