BackmediumStrings Cred Infosys

Anagrammed Bookshelf IDs Solution

Problem Statement

Given a library's database of N book collections, each denoted by a string of unique alphanumeric characters, find the unique identifier for each collection by anagramming the tool type, the returned status (success/error), and the corresponding collection ID. The library uses tools with different names, each returning one of two statuses, and they maintain a catalog of unique collection IDs. Your task is to generate these IDs from the given information.

Example 1
Input
['ErrorToolA Success1', 'ErrorToolZ Error2', 'SuccessToolA Success3', 'ErrorToolX Error4']
Output
['1: ErrorToolA Success', '2: ErrorToolZ Error', '3: SuccessToolA Success', '4: ErrorToolX Error']

Explanation: Step 1: Sort the input array by the tool type and status. Step 2: Iterate over the sorted array and create the output string by concatenating the collection ID, tool type, and status.

Example 2
Input
['SuccessToolB Success5', 'ErrorToolY Error6', 'ErrorToolW Error7', 'SuccessToolC Success8']
Output
['5: SuccessToolB Success', '6: ErrorToolY Error', '7: ErrorToolW Error', '8: SuccessToolC Success']

Explanation: Step 1: Sort the input array by the tool type and status. Step 2: Iterate over the sorted array and create the output string by concatenating the collection ID, tool type, and status.

Constraints

  • 1 ≤ N ≤ 10^5
  • Each tool name has a maximum length of 10 characters
  • Each status (success/error) is exactly 8 characters long (including the spaces)
  • Each collection ID is a positive integer with up to 6 digits
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free