A small python Dictionary query
Budget: ₹600 – ₹601 INR
You are given an array(list) result that contains hashmaps(dicts). The key value pairs are as
follows:
eventDate : DATE
Playtime : INTEGER
status : STRING
Find the difference in whole days between the minimum eventDate and the day the user status
converted to subscription.
If there is no subscription status, return -1.
You must write an algorithm with Linear or better runtime complexity.
Constraints:
status can only be trial or subscription
The array is not sorted
Example -
Input:
[ {eventDate: ’2022-06-02’, playtime: 4, status: ‘trial’},
{eventDate: ’2022-06-01’, playtime: 6, status: ‘trial’},
{eventDate: ’2022-06-04’, playtime: 10, status: ‘subscription’} ]
Result:
3
follows:
eventDate : DATE
Playtime : INTEGER
status : STRING
Find the difference in whole days between the minimum eventDate and the day the user status
converted to subscription.
If there is no subscription status, return -1.
You must write an algorithm with Linear or better runtime complexity.
Constraints:
status can only be trial or subscription
The array is not sorted
Example -
Input:
[ {eventDate: ’2022-06-02’, playtime: 4, status: ‘trial’},
{eventDate: ’2022-06-01’, playtime: 6, status: ‘trial’},
{eventDate: ’2022-06-04’, playtime: 10, status: ‘subscription’} ]
Result:
3