Samwell laid out N bowls in a straight line and put a few marbles randomly in each bowl, i^{th} bowl has A[i] marbles. A bowl can never have more than 9 marbles at a time. A bowl can have zero marbles. Now Samwells friend adds one more marble to the last bowl, after this addition all the bowls must still be aligned with the rules mentioned above. Adding a marble follows the same rules as of addition with carryover. You are given the initial list of the number of marbles in each bowl find the position of the bowl which was last modified. It is guaranteed that there is at least one bowl which has at least one space left.
Note: Consider one-based indexing.
Input:
N = 4
A[] = {3, 1, 4, 5}
Output: 
4
Explanation: 
The last bowl has 5 marbels, we can just 
add the marbel here.
Example 2:
Input:
N = 3
A[] = {1, 9, 9}
Output: 
1
Explanation: 
When we add the marbel to last bowl we 
have to move one marbel to 2nd bowl, 
to add the marbel in 2nd bowl we have 
to move one marbel to 1st bowl.
Hence the last modified bowl is 1.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function solve( ) which takes N and A[ ] as input parameters and returns the position of the last modified bowl.
Constraints:
1 ≤ N ≤ 10^{5}
0^{ }≤ A[i] ≤ 9

Difficulty: EASY
Tags: Mathematics

Starter code:
#User function Template for python3



class Solution():

    def solve(self, N, A):

        #your code here

        

Solutions:
class Solution:

	def solve(self, n, a):
		for i in range(n - 1, 0, -1):
			if a[i] < 9:
				return i + 1


class Solution:

	def solve(self, N, A):
		if A[N - 1] < 9:
			return N
		else:
			for i in range(N - 1, -1, -1):
				if A[i] > 8:
					continue
				else:
					return i + 1


class Solution:

	def solve(self, N, A):
		for i in range(N - 1, -1, -1):
			if A[i] + 1 <= 9:
				break
		return i + 1


class Solution:

	def solve(self, N, A):
		for i in range(n - 1, -1, -1):
			if A[i] < 9:
				return i + 1
		return 0


class Solution:

	def solve(self, N, A):
		carry = 1
		for i in range(N - 1, -1, -1):
			A[i] += carry
			carry = A[i] // 10
			A[i] %= 10
			if not carry:
				return i + 1
		return 0


class Solution:

	def solve(self, N, A):
		i = N - 1
		while i >= 0:
			if A[i] != 9:
				return i + 1
			i -= 1


class Solution:

	def solve(self, N, A):
		m = 0
		i = 1
		while i <= N and m == 0:
			if A[N - 1] < 9:
				m = 1
			else:
				N -= 1
		return N


class Solution:

	def solve(self, N, A):
		if A[-1] != 9:
			return len(A)
		k = True
		while k:
			if A[-1] == 9:
				A.pop()
			else:
				break
		return len(A)


class Solution:

	def solve(self, N, A):
		i = N - 1
		carry = 1
		while i >= 0 and carry:
			res = A[i] + carry
			carry = res // 10
			A[i] = res % 10
			i -= 1
		return i + 2


class Solution:

	def solve(self, N, A):
		index = 0
		for i in range(N - 1, -1, -1):
			if A[i] > 8:
				continue
			else:
				index = i
				break
		return index + 1


class Solution:

	def solve(self, N, A):
		i = len(A) - 1
		k = len(A) - 2
		if A[-1] + 1 <= 9:
			return len(A)
		else:
			while k >= 0:
				if A[k] + 1 <= 9:
					return k + 1
					break
				k -= 1


class Solution:

	def solve(self, n, a):
		carry = 0
		for i in range(n - 1, -1, -1):
			if a[i] + 1 + carry < 10:
				return i + 1
			carry = 1


class Solution:

	def solve(self, N, arr):
		for i in range(N - 1, -1, -1):
			if arr[i] < 9:
				return i + 1


class Solution:

	def solve(self, n, a):
		if a[n - 1] <= 8:
			return len(a)
		else:
			for i in range(n - 1, -1, -1):
				if a[i] <= 8:
					return i + 1


class Solution:

	def solve(self, N, A):
		modified = 0
		for i in range(N):
			if A[i] >= 9:
				continue
			modified = i + 1
		return modified


class Solution:

	def solve(self, N, A):
		last = len(A)
		while 1:
			A[last - 1] = A[last - 1] + 1
			if A[last - 1] <= 9:
				return last
			else:
				last = last - 1


class Solution:

	def solve(self, n, a):
		i = n
		while i > 0:
			if a[i - 1] == 9:
				i -= 1
			else:
				break
		else:
			return 0
		return i


class Solution:

	def solve(self, n, a):
		c = 1
		for i in range(n - 1, -1, -1):
			if a[i] + c > 9:
				c = 1
			else:
				return i + 1
		return 1


class Solution:

	def solve(self, N, bowls):
		i = len(bowls) - 1
		while i >= 0:
			if bowls[i] != 9:
				return i + 1
			i -= 1
		return -1


class Solution:

	def solve(self, N, bowls):
		i = len(bowls) - 1
		bowls[i] += 1
		while i > 0 and bowls[i] > 9:
			bowls[i] -= 10
			bowls[i - 1] += 1
			i -= 1
		return i + 1


class Solution:

	def solve(self, N, A):
		while A[N - 1] == 9:
			N = N - 1
			self.solve(N, A)
		return N


class Solution:

	def solve(self, N, A):
		carry = 0
		for i in range(N - 1, -1, -1):
			if A[i] + 1 + carry > 9:
				carry = 1
			else:
				ans = i + 1
				break
		return ans


class Solution:

	def solve(self, N, A):
		(s, c) = (0, 0)
		for i in range(N - 1, -1, -1):
			s = c + A[i] + 1
			if s <= 9:
				return i + 1
			c = s // 10


class Solution:

	def solve(self, N, A):
		A.reverse()
		ans = 0
		for i in range(N):
			if A[i] < 9:
				ans = N - i
				break
		return ans


class Solution:

	def solve(self, N, A):
		s = ''.join(list(map(str, A)))
		if s == '9' * N:
			return 0
		i = int(s)
		i += 1
		n = str(i).rjust(N, '0')
		for x in range(0, N):
			if s[x] != n[x]:
				return x + 1
		return 0


class Solution:

	def solve(self, N, A):
		j = len(A) - 1
		while j >= 0:
			if A[j] < 9:
				return j + 1
			j -= 1


class Solution:

	def solve(self, N, A):
		indx = 0
		for i in range(N - 1, -1, -1):
			if A[i] < 9:
				indx = i
				break
			else:
				continue
		return indx + 1


class Solution:

	def solve(self, N, A):
		for idx in range(len(A) - 1, -1, -1):
			A[idx] += 1
			if A[idx] <= 9:
				break
		return idx + 1


class Solution:

	def solve(self, N, A):
		for i in range(len(A) - 1, -1, -1):
			A[i] = A[i] + 1
			if A[i] > 9:
				A[i] = A[i] - 1
			else:
				return i + 1


class Solution:

	def solve(self, N, A):
		while A[-1] == 9:
			A.pop()
		return len(A)


class Solution:

	def solve(self, N, A):
		for i in range(N - 1, 0, -1):
			if A[i] < 9:
				return i + 1
			else:
				obj.solve(i, A)


class Solution:

	def solve(self, N, A):
		for i in range(N - 1, -1, -1):
			if A[i] <= 8:
				return i + 1


class Solution:

	def solve(self, N, A):
		A.reverse()
		v = -1
		for i in range(N):
			if A[i] == 9:
				v = i
			else:
				break
		if v == -1:
			return N
		return N - i


class Solution:

	def solve(self, N, A):
		carry = 1
		idx = N - 1
		while idx >= 0:
			if A[idx] + carry > 9:
				carry = 1
				idx -= 1
			else:
				return idx + 1


class Solution:

	def solve(self, N, A):
		while N > 0:
			if A[N - 1] <= 8:
				return N
			N = N - 1