Commonly asked Data Structures and Algorithms Problems by big tech and different solution approaches with code in Java and C

Powered by Blogger.

Wednesday, June 14, 2017

Grading Student Hackerrank solution in java


Problem : Student having grade > 37 needs to be rounded to next multiple of 5 if difference b/w next multiple and number is less than 3.


static int[] solve(int[] grades){
       for(int i=0;i<grades.length;i++)
           {
           if(grades[i]>37 && (5-grades[i]%5)<3)
               {
               grades[i]+=(5-grades[i]%5);
           }
       }
        return grades;
    }

0 Comments:

Post a Comment

Stats