Friday, 16 November 2018

Not every range query require-"Fenwick tree" & "Segment tree" to build.

Pigeon Hall Principal:-
It says that for a given Array of numbers (A[i]>=1) , if you choose any interval 
[ s , e ] (where  "s=starting index" and "e=end index" ) then it is always possible to find a subArray or subSet of  [ s, e]   such that 
"sum of numbers of that subArray or subSet is always divisible by ( e - s + 1)".

for example:- Consider A=[1 , 3 , 6 , 2 , 7 , 8]  and [ s , e]=[1,4]   
Here, (e-s+1)=4  and  A( [ s , e] )=[3 , 6 ,2 , 7]   , consider the subArray [ 6 , 2 ] whose sum is 8 , which is divisible by 4. you can take any interval and verify it ,
 "it is always possible to find such subArray ( it may be whole interval itself )".

link to related question: https://www.hackerrank.com/contests/recode-4/challenges/watari-queries ,
where one can use this concept.

How To Setup Raspberry pi 3 first time with Desktop

Setup raspberry pi 3 for first with help of desktop Components Required 1.Raspberry Pi 3 2.SD card minimum  8GB 3.HDMI Cable 4.Data...