← All questions
Coding
Fill Array Zeros with Positive Integers to Satisfy Adjacent |diff| ≤ 1
Asked at
Zomato
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Ask whether adjacent absolute difference must equal one.
- 02Confirm whether existing nonzero values are fixed.
- 03Check feasibility between fixed anchors.
- 04Construct compatible alternating paths or use DP.
- 05Validate positivity and every adjacent pair.
Reference answer
Then expect these follow-ups
How do you prove the anchor feasibility condition?
Tests: correctness reasoning
What if the task asks for the number of fills?
Tests: follow-up reasoning
Hiring now
Zomato is hiring right now
landed applies to roles like these for you, on each company’s own site, with answers written for the role.
Get 5x interviews10 free auto-applies. No card.
Software Engineer – Back End
Gurugram, HR, India
Next question