Skip to content

Instantly share code, notes, and snippets.

@sazid
sazid / book_struct.c
Created April 25, 2017 15:03
Book structure in C
#include <stdio.h>
#include <string.h>
struct Book {
char title[100];
char author[100];
int number_of_pages;
};
int main() {
# We multiply 10s 4 times together to get 10000
print(10*10*10*10)
print(2*2*2*2*2)
from math import log, ceil
print(log(10000, 10)) # how many times do we multiply 10 together to get 10000?
print(log(32, 2)) # how many times do we multiply 2 together to get 32?
@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;
#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;
}
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;
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;
}
// arr[] = {4, 2, 3, 8, 1, 9}
// tree[]
// build(...)
// query(...)
// update(...)
int main() {
// 1 দিয়ে রুট নোড বুঝনো হয়েছে
build(1, 1, MX);
AIUBian Android App
## 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.
## 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.