Amazon Coding Question – Solved

2 Live
Given a string, how many different substrings exist in it that have no repeating characters? Two substrings are considered different if they have a different start or end index. Example s = "abac" The substrings that have no repeating characters in them are "a", "b", "a", "c", "ab", "ba", "ac", and "bac". Note that "aba" and "abac" do not qualify because the character 'a' is repeated in them. Also, note that two substrings, "a" and "a", both qualify because their start indices are different: s[0] and s[2]. There are 8 substrings that have no repeating characters. Function Description Complete the function findSubstrings in the editor below. findSubstrings has the following parameter: string s: the given string Returns int: the number of substrings in s that have no repeating characters Constraints 1 ≀ length of s ≀ 10⁡ s consists of only lowercase English letters, ascii['a'-'z']. Input Format For Custom Testing Sample Case 0 Sample Input For Custom Testing bcada

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |