diff --git a/Hackerrank/climbing_the_leaderboard.py b/Hackerrank/climbing_the_leaderboard.py new file mode 100644 index 00000000..80e262e1 --- /dev/null +++ b/Hackerrank/climbing_the_leaderboard.py @@ -0,0 +1,94 @@ +# Problem Link: https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem + +# Complete the climbingLeaderboard function below. +def climbingLeaderboard(scores, alice): + + def binsrch(scores,num): + """ + A binary search function that searches for a particular score in the scores + array, and returns a tuple containing the possible location of the scores + in the list and a boolean to show if the score existed in the list. + + Parameters + ------------------------------- + scores: list[int] + list of scores + num: int + integer to be searched in the scores list + + Returns + -------------------------------- + (pos,isFound): (int,bool) + a tuple containing the (possilbe) position of num in the scores array + and a boolean to indicate if the score was found in the array. + + """ + start = 0 + end = len(scores)-1 + + while start<=end: + mid = start + int((end-start)/2) + + if scores[mid]>num: + start = mid+1 + elif scores[mid] | India | Python, Android, Java, Javascript | https://www.linkedin.com/in/deepanshu-sinha/ | | [Jared Moser](https://github.com/JM0S3R)
| United States | C++, Javascript | | | [Matei Oltean](https://github.com/Matei13)
| France | OCaml | | +| [Chaitanya Mattey](https://github.com/cmattey/)
| United States | Python | | | [Andreas Petridis](https://github.com/petridisa)
| Greece | Java | | | [Lam Tran](https://github.com/Lam7150)
| United States | Java | http://linkedin.com/in/lamgtran/ |