Input: arr[] = {0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1}
Output: No
Explanation:
Following are the operations performed on the array:
{0, 1, 1} -> 1 modifies the array to {1, 1, 1, 0, 0, 1, 1, 1, 1}
{1, 0, 0} -> 0 modifies the array to {1, 1, 0, 1, 1, 1, 1}
{1, 0, 1} -> 1 modifies the array to {1, 1, 1, 1, 1}
Since, all the remaining elements are 1, they remain unchanged.
Therefore, the array cannot be reduced to a single element.
Input: arr[] = {1, 0, 0, 0, 1, 1, 1}
Output: Yes
Explanation:
Following are the operations performed on the array:
{1, 0, 0} -> 0 {0, 0, 1, 1, 1}
{0, 0, 1} -> 0 {0, 1, 1}
{0, 1, 1} -> 1 {1}