Can we find Bitwise And of all subarrays of an array in O(n) time ? If not,then what is the best time complexity for doing this ?
| # | User | Rating |
|---|---|---|
| 1 | ecnerwala | 3844 |
| 2 | Benq | 3792 |
| 3 | tourist | 3719 |
| 4 | VivaciousAubergine | 3647 |
| 5 | jiangly | 3616 |
| 6 | ksun48 | 3595 |
| 7 | Kevin114514 | 3491 |
| 8 | strapple | 3486 |
| 9 | Um_nik | 3376 |
| 10 | turmax | 3371 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 162 |
| 2 | adamant | 148 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 133 |
Can we find Bitwise And of all subarrays of an array in O(n) time ? If not,then what is the best time complexity for doing this ?
bool findLoop(int v)
{
if(vis[v]==1)
return 1;
if(vis[v]==2)
return 0;
vis[v]=1;
for(auto &it:g[v])
{
if(findLoop(it))
return 1;
}
vis[v]=2;
return 0;
}
bool checkLoop()
{
fill(vis+1, vis+n+1, 0);
for(int i=1;i<=n;i++)
{
if(!vis[i] && findLoop(i))
return 1;
}
return 0;
}
| Name |
|---|


