Given a list of names, display the longest name.
Example:
Input:
N = 5
names[] = { "Geek", "Geeks", "Geeksfor",
  "GeeksforGeek", "GeeksforGeeks" }
Output:
GeeksforGeeks
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function longest() which takes the array names[] and its size N as inputs and returns the Longest name in the list of names.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N <= 100
1 <= |length of name| <= 1000

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def longest(self, names, n):

    	# code here

    	

    	

Solutions:
class Solution:

	def longest(self, names, n):
		length = []
		for i in names:
			length.append(len(i))
		index = length.index(max(length))
		return names[index]


class Solution:

	def longest(self, names, n):
		long_Name = names[0]
		for i in range(n):
			if len(names[i]) > len(long_Name):
				long_Name = names[i]
		return long_Name


class Solution:

	def longest(self, names, n):
		result = []
		for i in names:
			result.append(len(i))
		ma = result.index(max(result))
		return names[ma]


class Solution:

	def longest(self, names, n):
		max_len = 0
		index = 0
		for (i, name) in enumerate(names):
			if len(name) > max_len:
				max_len = len(name)
				index = i
		return names[index]


class Solution:

	def longest(self, names, n):
		a = []
		lenth = 0
		n = len(names)
		for i in range(0, n):
			lenth = len(names[i])
			a.append(lenth)
		max1 = max(a)
		max2 = a.index(max1)
		return names[max2]


class Solution:

	def longest(self, names, n):
		max1 = 0
		n = len(names)
		lenth = 0
		for i in range(0, n):
			lenth = len(names[i])
			if lenth > max1:
				max1 = lenth
				s = names[i]
		return s


class Solution:

	def longest(self, names, n):
		big = ''
		for i in names:
			if len(i) > len(big):
				big = i
		return big


class Solution:

	def longest(self, names, n):
		result = ''
		for name in names:
			if len(name) > len(result):
				result = name
		return result


class Solution:

	def longest(self, names, n):
		t = 0
		for i in range(len(names)):
			if len(names[i]) > t:
				t = len(names[i])
				k = names[i]
		return k


class Solution:

	def longest(self, names, n):
		max = names[0]
		for i in range(1, n):
			if len(max) < len(names[i]):
				max = names[i]
		return max


class Solution:

	def longest(self, names, n):
		d = 0
		a = ''
		for i in names:
			if d < len(i):
				d = len(i)
				a = i
		return a


class Solution:

	def longest(self, names, n):
		Max = pointer = 0
		for i in range(n):
			if len(names[i]) > Max:
				Max = len(names[i])
				pointer = i
		return names[pointer]


class Solution:

	def longest(self, names, n):
		length = list()
		for i in range(0, n):
			a = len(names[i])
			length.append(a)
		Max = max(length)
		Syn = length.index(Max)
		return names[Syn]


class Solution:

	def longest(self, names, n):
		max_len_index = -1
		max_len = -1
		for i in range(0, len(names)):
			if len(names[i]) > max_len:
				max_len = len(names[i])
				max_len_index = i
		return names[max_len_index]


class Solution:

	def longest(self, names, n):
		return max(names, key=len)


class Solution:

	def longest(self, names, n):
		arr = []
		for n in names:
			arr.append(len(n))
		return names[arr.index(max(arr))]


class Solution:

	def longest(self, names, n):
		num = 0
		p = 0
		for i in range(n):
			if len(names[i]) > num:
				num = len(names[i])
				p = i
		return names[p]


class Solution:

	def longest(self, names, n):
		l = []
		for i in range(n):
			l.append(len(names[i]))
		idx = 0
		m = max(l)
		for i in range(n):
			if l[i] == m:
				idx = i
		return names[idx]


class Solution:

	def longest(self, names, n):
		maxi = ''
		m = 0
		for i in names:
			if m < len(i):
				maxi = i
				m = len(i)
		return maxi


class Solution:

	def longest(self, names, n):
		maximum = ' '
		for a in names:
			if len(a) > len(maximum):
				maximum = a
		return maximum


class Solution:

	def longest(self, names, n):
		ans = []
		for name in names:
			ans.append(len(name))
		return names[ans.index(max(ans))]


class Solution:

	def longest(self, names, n):
		m = 0
		for ele in names:
			if len(ele) > m:
				m = len(ele)
				lon = ele
		return lon


class Solution:

	def longest(self, names, n):
		max_length = 0
		index = ''
		for i in names:
			length = len(i)
			if max_length < length:
				max_length = length
				index = i
		return index


class Solution:

	def longest(self, names, n):
		return sorted(names, reverse=True, key=lambda x: len(x))[0]


class Solution:

	def longest(self, names, n):
		dic = {}
		for i in names:
			dic[len(i)] = i
		return dic[max(dic.keys())]


class Solution:

	def longest(self, names, n):
		k = []
		for i in range(n):
			k.append(len(names[i]))
		maax = max(k)
		for i in range(n):
			if len(names[i]) == maax:
				return names[i]


class Solution:

	def longest(self, names, n):
		max_lenght = 0
		longest_name = ''
		for name in names:
			for name in names:
				if len(name) > max_lenght:
					max_lenght = len(name)
					longest_name = name
		return longest_name


class Solution:

	def longest(self, names, n):
		lent = 0
		for i in names:
			current_string_len = len(i)
			if current_string_len > lent:
				lent = current_string_len
		for i in names:
			if len(i) == lent:
				return i


class Solution:

	def longest(self, names, n):
		max_length = 0
		result = ''
		for i in range(n):
			element = names[i]
			curr_length = len(element)
			if curr_length > max_length:
				result = element
				max_length = curr_length
		return result


class Solution:

	def longest(self, names, n):
		lar = []
		for i in names:
			lar.append(len(i))
		for i in names:
			if len(i) == max(lar):
				return i


class Solution:

	def longest(self, names, n):
		y = names[0]
		longlength = len(y)
		x = 1
		while x < n:
			if len(names[x]) > longlength:
				y = names[x]
				longlength = len(y)
			x += 1
		return y


class Solution:

	def longest(self, names, n):
		max = 0
		e = ''
		for ele in names:
			if len(ele) > max:
				max = len(ele)
				e = ele
		return e


class Solution:

	def longest(self, names, n):
		len_ele = 0
		element = ''
		for i in names:
			if len_ele <= len(i):
				element = i
				len_ele = len(i)
		return element


class Solution:

	def longest(self, names, n):
		maxi = 0
		for i in names:
			maxi = max(maxi, len(i))
			if maxi == len(i):
				val = i
		return val


class Solution:

	def longest(self, names, n):
		len_array = ''
		for name in names:
			if len(name) > len(len_array):
				len_array = name
				return len_array

class Solution:

	def longest(self, names, n):
		output = ''
		for i in names:
			if len(i) > len(output):
				output = i
		return output


import operator

class Solution:

	def longest(self, names, n):
		d = {}
		for i in names:
			d[i] = len(i)
		l = [[i, d[i]] for i in d]
		l = sorted(l, reverse=True, key=operator.itemgetter(1))
		return l[0][0]


class Solution:

	def longest(self, names, n):
		wrd = ''
		max = 0
		for i in names:
			if len(i) > max:
				wrd = i
				max = len(i)
		return wrd


class Solution:

	def longest(self, names, n):
		l = -1
		for i in names:
			if len(i) > l:
				l = len(i)
				res = i
		return res


class Solution:

	def longest(self, names, n):
		max_l = ''
		for i in range(n):
			length = len(names[i])
			if len(max_l) < length:
				max_l = names[i]
		return max_l


class Solution:

	def longest(self, names, n):
		Max = names[0]
		for i in names[1:]:
			if len(i) > len(Max):
				Max = i
		return Max


class Solution:

	def longest(self, names, n):
		names = sorted(names, key=len)
		return names[n - 1]


class Solution:

	def longest(self, a, n):
		out = a[0]
		for i in range(n):
			if len(a[i]) > len(out):
				out = a[i]
		return out


class Solution:

	def longest(self, names, n):
		a = []
		for i in names:
			a.append(len(i))
			b = a.index(max(a))
		return names[b]


class Solution:

	def longest(self, names, n):
		name = None
		max = len(names[0])
		for i in range(len(names)):
			if max <= len(names[i]):
				name = names[i]
				max = len(names[i])
		return name


class Solution:

	def longest(self, names, n):
		length = 0
		greater = ''
		for i in names:
			str1 = str(i)
			length1 = len(str1)
			if length1 > length:
				length = length1
				greater = str1
		return greater


class Solution:

	def longest(self, names, n):
		names.sort(key=len)
		return names[-1]


class Solution:

	def longest(self, names, n):
		len_ctr = 0
		index = -1
		for i in range(n):
			if len(names[i]) > len_ctr:
				len_ctr = len(names[i])
				index = i
		return names[index]


class Solution:

	def longest(self, names, n):
		l = 0
		for i in range(n):
			if len(names[i]) > l:
				l = len(names[i])
				x = names[i]
		return x


class Solution:

	def longest(self, names, n):
		length = 0
		index = 0
		ind = 0
		for i in names:
			if length < len(i):
				length = len(i)
				ind = index
			index += 1
		return names[ind]


class Solution:

	def longest(self, names, n):
		ma = float('-inf')
		out = ''
		for name in names:
			if len(name) > ma:
				ma = len(name)
				out = name
		return out


class Solution:

	def longest(self, names, n):
		d = {}
		for i in names:
			d[len(i)] = i
		l = [i for i in d.keys()]
		a = sorted(l)
		return d[a[-1]]


class Solution:

	def longest(self, names, n):
		max = 0
		stri = ''
		for i in names:
			a = len(i)
			if a > max:
				stri = i
				max = a
		return stri


class Solution:

	def longest(self, names, n):
		lendict = {}
		for i in names:
			lendict[i] = len(i)
		max_len = max(lendict.values())
		for i in lendict.keys():
			if lendict[i] == max_len:
				return i


class Solution:

	def longest(self, names, n):
		temp = 0
		for i in range(n):
			if len(names[i]) > temp:
				temp = len(names[i])
				index = i
		return names[index]