Tje lights problem

https://practice.geeksforgeeks.org/problems/the-light-problem4217/1
how can we do this problem explain me a lil bit

Steps to solve the question

  1. make a brightness array which will store whether current cubic is brighten or not
  2. now traverse from start to end and mark all cubics which will be brighten by bulbs
  3. 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)
  4. 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