Check out example codes for "blogger". It will help you in understanding the concepts better.

Code Example 1

int fen[MAX_N];
void update(int p,int val){
	for(int i = p;i <= n;i += i & -i)
		fen[i] += val;
}
int sum(int p){
	int ans = 0;
	for(int i = p;i;i -= i & -i)
		ans += fen[i];
	return ans;
}

Learn ReactJs, React Native from akashmittal.com