Skip to content

Instantly share code, notes, and snippets.

// Holds the graph
map<char, vector<char>> graph;
// Status of each node - UNVISITED, VISITING, VISITED
map<char, int> status;
// This will denote whether the graph has cycles
bool hasCycles = false;
// Status codes
@sazid
sazid / init.vim
Created March 27, 2019 16:59
(n)vim config file
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
" set smarttab
set expandtab
" set number
set relativenumber
## Privacy Policy
Sazid built the Unlockify app as an Ad Supported app. This SERVICE is provided by Sazid at no cost and is intended for use as is.
This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Unlockify unless otherwise defined in this Privacy Policy.
## Privacy Policy
Sazid built the Locker app as an Ad Supported app. This SERVICE is provided by Sazid at no cost and is intended for use as is.
This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Locker unless otherwise defined in this Privacy Policy.
AIUBian Android App
// arr[] = {4, 2, 3, 8, 1, 9}
// tree[]
// build(...)
// query(...)
// update(...)
int main() {
// 1 দিয়ে রুট নোড বুঝনো হয়েছে
build(1, 1, MX);
void update(int node, int b, int e, int i, int newval) {
// index is out of range
if (b > i || e < i) return;
// we're at leaf node
if (b == i && e == i) {
tree[node] = newval;
a[i] = newval;
return;
}
int query(int node, int b, int e, int l, int r) {
// no overlap
if (b > r || e < l) return 0;
// total overlap
if (b >= l && e <= r) return tree[node];
// partial overlap
int left = 2*node;
int right = 2*node + 1;
#define MX 6
int arr[MX];
int tree[MX*4];
void build(int node, int b, int e) {
if (b == e) {
tree[node] = arr[b];
return;
}
@sazid
sazid / cumulative_sum.cpp
Last active June 17, 2018 21:32
Segment tree
int arr[5] = {4, 2, 3, 8, 1, 9};
int sum[5] = {4};
for (int i = 1; i < 5; i++) sum[i] = sum[i-1] + arr[i];
int a = 1, b = 3;
// print the sum for the range [a,b]
cout << sum[b]-sum[a-1] << endl;