Sollicitatievraag bij 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.

Antwoorden op sollicitatievragen

Anoniem

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

Anoniem

16 apr 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

Anoniem

1 okt 2018

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

Anoniem

14 mrt 2017

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