Round 1
Questions:
Question 1: Valid database ids kind of (easy/medium)
This question basically said there will be given 'n' strings in an array, we need to validate whether the sequence is a valid database ids' sequence or not. For example: ["0001....73", "0005...d8", "0002...7c", ...]. Basically the validation consisted of the following steps checking:
- Each database ids should be of length 14, of which first 4 characters represent sequence of entry in db, and rest 10, it's unique_id (alphanumeric). This should be unique, so there shouldn't be any duplicate ids coming in the sequence.
- The first 4 characters should be always between 1->n (Integer), such that no duplicates are there, and no 1->n numbers are skipped.
- Finally, return the sequence in proper order, starting from lowest sequence number to highest, if invalid, return "-1" or "Invalid".
Question 2: Valid data parsing (easy/medium)
Given a list of strings of format like this: [ "{ "container_id": "43dde3....", "status_log": "Success" }", "{ "container_id": "4872dd......", "status_log": "Fail" }", "{ "container_id": "7d3453......", "status_log": "dkvhidshbitri" }" ] We have to return an array like this [successCount, failureCount, invalidCount]. So, basically status_log would define success or fail, and if anything, any data-parsing error comes in any particular string, which is not of the proper formats, we need to take in out invalidCount. Also, we need to take care of the following validations gracefully:
- The key names, should match the exact naming conventions as given.
- The container_id consists of 10 characters, and all is alphanumeric.
- The status_log only has 2 valid types - Success or Fail.
- Use proper string processing, keeping all the exceptions coming in mind.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.