https://practice.geeksforgeeks.org/problems/the-light-problem4217/1
how can we do this problem explain me a lil bit
Tje lights problem
Steps to solve the question
- make a brightness array which will store whether current cubic is brighten or not
- now traverse from start to end and mark all cubics which will be brighten by bulbs
- now traverse from end to start and mark all cubics which will be brighten by bulbs (this is because from a bulb both cubics are brighten which are k distance ahead and which are k distance behind)
- now at last just check all cubics are brighten or not and return ans accordingly
Reference Code
got it …
sir if we have to find min numbers of bulbs to be on so that every cubical brights??
then it will be
n/(2*K) +1