Question d’entretien chez 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.

Réponses aux questions d'entretien

Utilisateur anonyme

28 oct. 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).

Utilisateur anonyme

16 avr. 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

Utilisateur anonyme

1 oct. 2018

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

Utilisateur anonyme

14 mars 2017

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