![]() |
VOOZH | about |
Given a binary array, find Bitwise OR of the given array.
Examples :
Input: arr[] = [1 1 1 0]
Output:1
Explanation:
1 | 1 = 1
1 | 1 = 1
1 | 0 = 1
hence output is 1Input: arr[] = [0 0 1 0]
Output: 1
Explanation:
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
hence output is 1
Table of Content
The OR gate outputs 1 if at least one input is 1. Simply iterate through all bits and compute cumulative OR using bitwise OR operator.
1
OR gate outputs 1 if at least one input is 1. Scan the array and return 1 immediately when a 1 is found. If no 1 is found after scanning all elements, return 0.
1