4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

[HackerRank] Grading Students

algorithm.png

문제



출처 - HackerRank


풀이


나머지 연산을 이용합니다.

public class Solution {
    static int[] gradingStudents(int[] grades) {
        
        for (int i = 0; i < grades.length; i++) {
            // 점수가 38점 이상이며 5로 나눈 나머지가 3 이상이면 반올림
            if (grades[i] >= 38 && (grades[i] % 5) >= 3) {
                grades[i] += 5 - (grades[i] % 5);
            }
        }
        
        return grades;
    }
}

2 upvotes $0.06

Replies (0)

Conversation

No replies yet

Replies will appear here as people join the conversation.

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: