Amazon Online Assessment Questions | SDE 1
Anonymous User
1175

Problem 1:
image

Problem 2:
image
Problem statement:
The problem requires identifying the length of the longest self-sufficient substring in a given string S with size n consisting of lowercase letters. Find the longest self-sufficient substring.

Definition of a self-sufficient substring:

  • It can't be full string. ( means answer should be less than n )
  • No letter in the substring occurs both inside and outside the substring. (mean all occurence of a particular letter should be included in a substring or none)

Constraints: 1<= n<= 1e5
Output: The length of the longest self-sufficient proper substring. If no such substring exists, return 0.

Example:
S = "amazonservices"
O/p = 11 as "zonservices" is substring of maximum length which satisfy the condition.

Valid substrings are:
"amazon", "services", "ama", "ervice"
Invalid substrings are:
"amazonservices", "amazonservice", "amazons"

You can share your approaches.
Cheers!!

Comments (7)