Skip to content

Latest commit

 

History

History
71 lines (45 loc) · 5.38 KB

CorrectScholarships.md

File metadata and controls

71 lines (45 loc) · 5.38 KB

Correct Scholarships


For the upcoming academic year the Coolcoders University should decide which students will get the scholarships. Scholarships are considered to be correctly distributed if all best students have it, but not all students in the university do. Obviously, only university students should be able to get a scholarship, i.e. there should be no outsiders in the list of the students that will get a scholarships.

You are given lists of unique student ids bestStudentsscholarships and allStudents, representing ids of the best students, students that will get a scholarship and all the students in the university, respectively. Return true if the scholarships are correctly distributed and false otherwise.

Example

  • For bestStudents = [3, 5]scholarships = [3, 5, 7], and
    allStudents = [1, 2, 3, 4, 5, 6, 7], the output should be
    solution(bestStudents, scholarships, allStudents) = true;

  • For bestStudents = [3, 5]scholarships = [3, 5], and
    allStudents = [3, 5], the output should be
    solution(bestStudents, scholarships, allStudents) = false.

    All students get a scholarship, which is not correct.

  • For bestStudents = [3]scholarships = [1, 3, 5], and
    allStudents = [1, 2, 3], the output should be
    solution(bestStudents, scholarships, allStudents) = false.

    There's no student with id 5, yet somehow he managed to get a scholarship.

Input/Output

  • [execution time limit] 4 seconds (py3)

  • [input] array.integer bestStudents

    Array of unique elements representing ids of the best students in the university. It is guaranteed that all bestStudents are present in allStudents.

    Guaranteed constraints:
    0 ≤ bestStudents.length ≤ 30,
    1 ≤ bestStudents[i] ≤ 1000.

  • [input] array.integer scholarships

    Array of unique elements representing ids of the students that will get a scholarship.

    Guaranteed constraints:
    0 ≤ scholarships.length ≤ 30,
    1 ≤ scholarships[i] ≤ 1000.

  • [input] array.integer allStudents

    Array of unique elements representing ids of the students that will get a scholarship.

    Guaranteed constraints:
    0 ≤ allStudents.length ≤ 30,
    1 ≤ allStudents[i] ≤ 1000.

  • [output] boolean

    true if the scholarships are correctly distributed and false otherwise.



Solution

def solution(bestStudents, scholarships, allStudents):
    return set(bestStudents) <= set(scholarships) < set(allStudents)

See on app.codesignal.com