UME14

Hackerrank_ClimbingTheLeaderboard

Sep 29th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. //scores = [100, 100, 50, 40, 40, 20, 10]
  14. //alice = [5, 25, 50, 120]
  15.  
  16. System.out.println(climbingLeaderboard([100, 100, 50, 40, 40, 20, 10], [5, 25, 50, 120]));
  17. }
  18.  
  19. static int[] climbingLeaderboard(int[] scores, int[] alice)
  20. {
  21. int count = 0, res = 0;
  22. for (int i=0; i++; i<scores.length()-1):
  23. if (scores[i]>scores[i+1]):
  24. {
  25. count += 1;
  26. for (int j=0; j++; j<alice.length())
  27. {
  28. if (alice[i]>scores[i])
  29. {
  30. res = count;
  31. }
  32. else if (alice[i]<scores[])
  33. {
  34. res = count + 1;
  35. }
  36. }
  37. }
  38. return res;
  39.  
  40. }
  41. }
Add Comment
Please, Sign In to add comment