Pergunta de entrevista da empresa Meta

1)- programmingl find the max no from the given set of elements in an array (without using max function) 2)- Find the minimum absolute difference between the set of elements of an array.

Respostas da entrevista

Sigiloso

28 de out. de 2017

For 1 you need not sort it, sorting is O(NlogN), you can just traverse once keeping track of max number and replacing it when u find something larger than that. This would be O(N).

Sigiloso

16 de abr. de 2018

2nd wont work if there is a negative value. My solution n = input() val = 100**100 arr = map(int, raw_input().split()) arr.sort() for i in range(n - 1): val = min(val, abs(arr[i] - arr[i+1])) print val

Sigiloso

1 de out. de 2018

l={1,4,5,7,6,4,3} max=0 for i in l: if i > max: max=i print(max)

Sigiloso

14 de mar. de 2017

1) sort in descending order and print the first element 2) sort in ascending order and report the difference between the first two