Given N bits to an OR - Gate find the output that will be produced. 
OR - Gate Table:
1 | 1 = 1
1 | 0 = 1
0 | 1 = 1
0 | 0 = 0
 
Example 1:
Input:
N = 4
arr: 1 1 1 0
Output:
1
Explanation:
1 | 1 = 1
1 | 1 = 1
1 | 0 = 1
hence output is 1
Example 2:
Input:
N = 4
arr: 0 0 1 0
Output:
1
Explanation:
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
hence output is 1
Your Task:
You don't need to read input or print anything. Your task is to complete the function orGate() which takes the array arr[], its size N as input parameters and returns the output after processing OR operations on N bits.
 
Expected Time Complexity: O(N)
Expected Space Complexity: O(1)
 
Constraints:
1<=N<=1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Bit manipulation

Data structures

Starter code: #User function Template for python3

class Solution:

    def orGate (self, arr, N):

        # code here 

Solutions:
class Solution:

	def orGate(self, arr, N):
		if 1 in arr:
			return 1
		return 0


class Solution:

	def orGate(self, arr, N):
		output = 0
		for i in range(N):
			a = bool(arr[i]) | bool(arr[i + 1])
			if a == True:
				output = 1
		return output


class Solution:

	def orGate(self, arr, N):
		ans = arr[0]
		for i in range(1, N):
			ans = ans or arr[i]
		return ans


class Solution:

	def orGate(self, arr, N):
		for i in range(N - 1):
			if arr[i] | arr[i + 1] == 1:
				return 1
		return 0


class Solution:

	def orGate(self, arr, N):
		return int(any(arr))


class Solution:

	def orGate(self, arr, N):
		temp = arr[0]
		for i in arr:
			if i or temp:
				temp = 1
			else:
				temp = 0
		return temp


class Solution:

	def orGate(self, arr, N):
		a = 0
		for i in range(0, N):
			a |= arr[i]
		return a


class Solution:

	def orGate(self, arr, N):
		if arr.count(1) >= 1:
			return 1
		else:
			return 0


class Solution:

	def orGate(self, arr, N):
		for i in arr:
			if arr.count(1) > 0:
				return 1
		else:
			return 0


class Solution:

	def orGate(self, arr, n):
		if 1 in arr:
			return 1
		else:
			return 0


class Solution:

	def orGate(self, arr, N):
		c = 0
		for x in arr:
			if x == 1:
				c = 1
		return c


class Solution:

	def orGate(self, arr, N):
		if N == 1:
			return arr[0]
		else:
			s = arr[0] | arr[1]
			for x in range(2, N):
				s |= arr[x]
			return s


class Solution:

	def orGate(self, arr, N):
		o = arr[0]
		for i in range(1, N):
			o = o | arr[i]
		return o
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		arr = input().split(' ')
		for itr in range(N):
			arr[itr] = int(arr[itr])
		ob = Solution()
		print(ob.orGate(arr, N))


class Solution:

	def orGate(self, arr, N):
		c = arr[0]
		for i in range(1, len(arr) - 1):
			c |= arr[i]
		return c


class Solution:

	def orGate(self, arr, N):
		if N == 1:
			return arr[0]
		elif N == 2:
			return arr[0] or arr[1]
		ans = arr[0] or arr[1]
		for i in range(2, N):
			ans = ans or arr[i]
		return ans


class Solution:

	def orGate(self, arr, N):
		check = False
		for i in range(len(arr)):
			if arr[i] == 1:
				check = True
		if check:
			return 1
		return 0