Mihai Surdeanu

Another example of question for interviews

Hi everyone,

Today, I’m going to continue the series of questions to be asked during a technical interview. This time, we are dealing more with a logical question and one feasible for almost all programming languages found on this planet.

Let’s start. You are dealing with two dates: DATE_START and DATE_END (DATE_START <= DATE_END) and a method getWeekDay which returns the day of the week as an integer, where Monday is 0 and Sunday is 6, for a given date. getWeekDay method is already implemented and tested.

Can you implement a method for deciding if between DATE_START and DATE_END there is a full weekend included, using only calls to getWeekDay (no other APIs are allowed)? A full weekend means at least one Saturday and one Sunday included.


  1. DATE_START = 25.05.2020, DATE_END = 30.05.2020 => The method returns False.
  2. DATE_START = 25.05.2020, DATE_END = 06.06.2020 => The method returns True.
  3. DATE_START = 30.05.2020, DATE_END = 31.05.2020 => The method returns True.

The idea is to avoid using a loop to iterate over all days between DATE_START and DATE_END to mark ones from weekend. It’s possible to implement an algorithm without using a loop?

Happy coding!


Pasionat de IT. Pasionat de viață. Pasionat de tot ceea ce înseamnă a face o viață mai bună, plină de înțelegere, ajutor reciproc și iubire de aproape.

Adaugă comentariu


Arhiva personală