AND Reachability DP Problem

n ho sakta hai but not always.

example->
index - value (in binary)
0 -> 001
1-> 011
2->010

now tell me dp[0][1]?
i mean go[0][1]

go[0][1]=1 hoga

go[3][3] ka table…

0 1 3
1 1 3
3 2 3

ha aur ye samjh mein aaya ki ye kaise hua ?

Kyun ki, I can jump from 0th index to 1th index through j(=0)th set bit…Nhi samjh aya, I believe…yah maine dry run karke pata kiye

ha mujhe bus yahi samjha tha tumhe. yahi mein crux tha is problem ka aur yahi mein yaha convey karna cha raha tha.

.
ab ek baar bus cf ke solution pe najar maar lo sab clear ho jayega.

Bhaiya, aap ek baar khud se bataye, esa kyun hua?
go[0][1]=1

Kyun ki, agar maan lijiye,
0 0 1
1 0 1
1 0 0

rahta, tab go[0][2]=1 hota?

Accha…

go[i][j]>=i hoga where ith index and jth bit
if(j==1)
go[i][j]=i
if(j==0)
go[i][j]>i

ha . . . . . . . … . .
0 0 1
0 1 1
1 1 0

iska batao go[0][2]

go[0][2]=2 hoga, kyun ki 0th index peh 2nd bit set karne ke lea mujhe 2 jump karna hai…

2 jo hai wo index hai not jump.

go[0][2]=2 because 2 is smallest index rechable from index 0 whose 2nd bit is set.(001->011 -> 110)

tab go[2][2] ka kya hoga?

its 2 only because 2nd bit is set

Sorry, go[2][0] ka kya hoga?

3 (i.e infinite ). . . … …
we cannot reach anywhere

0 0 1
0 1 1
0 1 0
isme, go[1][2]=infinity hoga?

Bhaiya, go[i][j]=k ka matlb hai ki,

index i se index k reachable hai, kyun ki index k meh j’th bit set(1) hai.

Aur index k ka value >=i ho sakta hai.

yes … . … …
and there is a path from i to k.

Bhaiya, global value N declare karne ke lea const kyun use karna hota hai?

static array ka size fixed hota hai, aur ek baar size de diya to baad mein hum use change nahi kar sakte.
isi condition ko valid rakhne ke liye N ko const banate hain.
ex->
int n=20;
int a[n];

agar mein n ki value baad mein change kar du to?
n=10
ye to voilate kar dega static array ka condition isiliye const jaruri hain