Problem Β· String
Find Number of Possible Unique Strings π
Learn this problemProblem statement
Given a string of lowercase characters, pick substring of any length in it and reverse them. Find the number of possible unique strings.
Function
findNumberOfPossibleUniqueStrings(s: String) β int
Complete the function findNumberOfPossibleUniqueStrings in the editor.
findNumberOfPossibleUniqueStrings has the following parameter:
String s: the input stringReturns
int: the number of possible unique strings
Examples
Example 1
s = "abc"return = 4Possible unique strings:
Substring of length 1:
Reversing a single character results in same original string.
For example reverse a in abc, gives abc
Substring of length 2:
Reverse ab (substring of length 2) in abc results in bac
Reverse bc (substring of length 2) in abc results in acb
Substring of length 3:
Reverse abc (substring of length 3) in abc results in cba
So return result as 4
Constraints
The length of the input string is 1 to 105More Amazon problems
- Secure Maximum DeliveriesOA Β· Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW Β· Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN Β· Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN Β· Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW Β· Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW Β· Seen Jul 2026
- Maximum System Memory CapacityOA Β· Seen Jul 2026
- Package Delivery SystemOA Β· Seen Jul 2026