Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
813 views
in Online Assessments by Expert (44,360 points) | 813 views

1 Answer

0 like 0 dislike
Assume, there is a Data store which stores documents, where each document has a field, documentDate, of string type in the format YYYYMMDDhhmmss.

 

Assume there is an Api, GetDocumentsCount(string datePrefix), which gets count of the documents where the documentDate starts with the prefix given.

 

For instance, call to GetDocumentsCount("201801") would return count of all the documents where documentDate string starts with 201801.

 

Write a function, GetDocumentsInRangeCount(string startDateTime, string endDateTime) which would make the minimal number of calls to GetDocumentsCount and fetching exactly the count of documents between the startDateTime and endDateTime , both inclusive.

 

As an example test case, reply with the minimal number of calls that would be made to GetDocumentsCount when startDateTime is 19700225000000 and the endDateTime is 20190430000000
by Expert (44,360 points)