Given an array arr[] of size N representing the size of candles which reduce by 1 unit each day. The room is illuminated using the given N candles. Find the maximum number of days the room is without darkness.
 
Example 1:
Input: N = 3, arr[] = {1,1,2} 
Output: 2
Explanation: The candles' length reduce 
by 1 in 1 day. So, at the end of day 1: 
Sizes would be 0 0 1, So, at end of 
day 2: Sizes would be 0 0 0. This means 
the room was illuminated for 2 days.
Example 2:
Input: N = 5, arr[] = {2,3,4,2,1} 
Output: 4
Your Task:
This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function maxDays() that takes array A[] and integer N as parameters and returns the desired output.
 
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).
 
Constraints:
1 ≤ N ≤ 10^{6}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: 

class Solution:

    def maxDays(self, arr, n):

        # code here

Solutions:
class Solution:

	def maxDays(self, arr, n):
		arr.sort()
		return arr[-1]


class Solution:

	def maxDays(self, arr, n):
		return max(arr)


class Solution:

	def maxDays(self, arr, n):
		m = -1
		for i in arr:
			if i > m:
				m = i
		return m


class Solution:

	def maxDays(self, arr, n):
		min = arr[0]
		for i in range(1, n):
			if arr[i] > min:
				min = arr[i]
		return min


class Solution:

	def maxDays(self, arr, n):
		max = arr[0]
		for i in range(n):
			if arr[i] > max:
				max = arr[i]
		return max


class Solution:

	def maxDays(self, arr, n):
		ans = -1
		for i in range(n):
			ans = max(ans, arr[i])
		return ans


class Solution:

	def maxDays(self, arr, n):
		max_num = arr[0]
		for elem in arr:
			if elem > max_num:
				max_num = elem
		return max_num


class Solution:

	def maxDays(self, arr, n):
		arr.sort(reverse=True)
		return arr[0]


class Solution:

	def maxDays(self, arr, n):
		m = arr[0]
		for i in range(1, n):
			m = max(m, arr[i])
		return m


class Solution:

	def maxDays(self, arr, n):
		maxi = 0
		for i in range(len(arr)):
			if maxi < arr[i]:
				maxi = arr[i]
		return maxi


class Solution:

	def maxDays(self, arr, n):
		list_n = list(arr)
		return max(list_n)


class Solution:

	def maxDays(self, arr, n):
		maxdays = arr[0]
		for i in arr:
			if i > maxdays:
				maxdays = i
		return maxdays


class Solution:

	def maxDays(self, arr, n):
		l = list(arr)
		return max(l)


class Solution:

	def maxDays(self, arr, n):
		max_ = -999999999999999
		for i in range(n):
			if arr[i] > max_:
				max_ = arr[i]
		return max_


class Solution:

	def maxDays(self, arr, n):
		md = -1
		for i in range(n):
			if md < arr[i]:
				md = arr[i]
		return md


class Solution:

	def maxDays(self, arr, n):
		m = 0
		for e in arr:
			if e > m:
				m = e
		return m


class Solution:

	def maxDays(self, arr, n):
		import heapq
		heapq._heapify_max(arr)
		a = heapq._heappop_max(arr)
		return a