Amazon Coding Question – Solved

12 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

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |