Microsoft Interview Question: Create a function that takes ... | Glassdoor

Interview Question

Intern Interview(Student Candidate) Cambridge, MA

Create a function that takes an attendance record (array of

  bools) and returns true if the student should be suspended. They should be suspended if: - they missed 3 or more days in a row - they missed 7 days total

Interview Answer

2 Answers


Doable with one for loop -- iterate through the array and count the number of "true"s, return true if it's >= 7. Also in the loop, if the current index is not the first or last, return true if the previous, current, and next indicies are true.

Bob on Oct 10, 2017

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

Add Answers or Comments

To comment on this, Sign In or Sign Up.