TikTok User
Problem Overview
- Given array arr (length n) with some 0s, count the ways to replace 0s so the array is "good" (adjacent values differ by at most 1).
- Nonzero entries are fixed; replacements can be any integers; output the count modulo 1e9+7.
- Domain: assigning smoothly varying user numbers in a TikTok system.
- From TikTok interviews; a coding interview problem and common interview question on arrays/counting.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
