We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Interview Preparation Kits
  3. 3 Months Preparation Kit
  4. Week 2
  5. Grading Students

Grading Students

Problem
Submissions
Leaderboard
Discussions
Editorial
HackerRank Logo
|
  1. Prepare
  2. Interview Preparation Kits
  3. 3 Months Preparation Kit
  4. Week 2
  5. Grading Students
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

HackerLand University has the following grading policy:

  • Every student receives a in the inclusive range from to .
  • Any less than is a failing grade.

Sam is a professor at the university and likes to round each student's according to these rules:

  • If the difference between the and the next multiple of is less than , round up to the next multiple of .
  • If the value of is less than , no rounding occurs as the result will still be a failing grade.

Examples

  • round to (85 - 84 is less than 3)
  • do not round (result is less than 40)
  • do not round (60 - 57 is 3 or higher)

Given the initial value of for each of Sam's students, write code to automate the rounding process.

Function Description

Complete the function gradingStudents in the editor below.

gradingStudents has the following parameter(s):

  • int grades[n]: the grades before rounding

Returns

  • int[n]: the grades after rounding as appropriate

Input Format

The first line contains a single integer, , the number of students.
Each line of the subsequent lines contains a single integer, .

Constraints

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website