Amazon Interview Question

Write a method to determine whether two dates are less than a month apart.

Interview Answers

Anonymous

Sep 23, 2015

Lots of if elses

Anonymous

Jan 16, 2016

easiest way is to convert them to days and subtract. if they are <=31 days apart, then true. the problem is question is a bit ambigious as what exactly a month apart means as different months have different days.

Anonymous

Mar 25, 2022

The question has no answer until more information is provided. What is a month apart? Is it 31 days, 30 days, 29 days, 28 days? Is it the day of month "number" for the later date is less than the day of month "number" for the earlier date? And other undefined conditions. All conditions must be known before a valid method can be defined and verified as valid.