Company: Trilogy_8aug

Difficulty: medium

Problem Statement

Almost Matching Substring Pairs Problem Description Suppose a text-processing tool supports an "almost equal" comparison between two strings: two strings qualify as almost matching when they have the same length and every character lines up the same except for exactly one position. For instance, "cat" and "bat" are almost matching, while "cat" and "dog" are not. Rather than compare unrelated strings, you will test this comparison using substrings drawn from one single string. Given a string s and an integer k , count how many pairs of substrings of s are almost matching and whose single differing position is exactly the k th character (0-based) of each substring. Both substrings in a pair must be long enough to have a k th character at all, or the pair cannot be counted. Substrings are identified by their start and end indices rather than their text, so the same word occurring more than once in s contributes multiple distinct substrings. For instance, in the word "ingratiating" the sub

More Trilogy_8aug OA questionsInterview experiences