meenalkumar
BAN USERI would follow these steps:
1. parse the input to collection of Customer objects where Customer {id, loginHistory}
2. filter Customers which has logged in for more than 4 times (or exactly 4 times, depending upon requirement)
3. for each filtered customer
3.1 sort the login history dates
3.1.1 for each login history date
3.1.1.1. subtract previous date from current date
3.1.1.1.1 if result is 1 i.e. diff is 1 day, repeat step above step for next date, until diff is 1 day
3.1.1.1.2 if result is not 1 day, then discard that customer and repeat from 3.1.1
4. result will be those customers which logged in on consecutive days for more than 4 days (or exactly 4 days)
singleton pattern with synchronization lock on the object, so that only single thread can access the target object.
- meenalkumar April 17, 2017
I would solve it using Breadth First Traversal technique and note down count of nodes at each level. Max counter is answer label.
- meenalkumar May 14, 2017