Environment

NodeJS/Express JS, JavaScript/TypeScript, MongoDB


What To Build

1. Create a Product

Implement functionality to create a product with the following attributes:

2. Generate Product Code

Product codes must be auto-generated based on the product name with the following steps:

  1. Extract the longest strictly increasing substring (consecutive letters in alphabetical order and lowercase).

  2. If multiple substrings of equal length exist, concatenate them.

  3. Append the starting and ending index of the substring in the product name.

  4. Add the hashed value of the product name at the beginning as a prefix with a dash (-).

  5. Format: The final product code should follow this structure:

    <hashed product name>-<start_index><substring><end_index>