Largest Element in Array

 Given an array A[] of size n. The task is to find the largest element in it.

 

Example 1:

Input:
n = 5
A[] = {1, 8, 7, 56, 90}
Output:
90
Explanation:
The largest element of given array is 90.
 

Example 2:

Input: 

n = 7

A[] = {1, 2, 0, 3, 2, 4, 5}

Output: 5

Explanation: The largest element of given array is 5.

 

 def largest( arr, n):
    return max(arr)


#{
#  Driver Code Starts
#Initial Template for Python 3

def main():

    T = int(input())

    while(T > 0):
        n = int(input())
        a = [int(x) for x in input().strip().split()]
        print(largest(a, n))

        T -= 1


if __name__ == "__main__":
    main()

 

 

Comments

Popular posts from this blog

Large Factorial of array

Value equal to index value