Distance from Each 1 to the Nearest 2 in an Array
Problem: Distance from Each 1 to the Nearest 2 in an Array
You are given an array arr of length n. Each element is one of 0, 1, or 2.
For every position whose value is 1, compute its ...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
