HackerRank Problem

Input : a[] = {2, 8, 7, 1, 5}
Output : 1 2 5
Explanation : The output three elements have two or more greater elements.

---------------->>>>Solution<<<----------
def findElements(self,a, n):
temp = sorted(a)
return temp[-3::-1][::-1]

I was just trying for this type of solution then I noticed that Nexted slicing is also possible

3 Likes

Thank you @sriv.ansh for sharing. Got to learn something new.

2 Likes

@sriv.ansh this is why it is so important to invest time in coding!! This is a great way to explore and become confident in one’s own abilities. Well done!

2 Likes