- 0of 0 votes
Given two strings s1, s2, write a function that returns true if s2 is a special substring s1. A special substring s2 is such that the s1 contains s2 where each character in s2 appears in sequence in s1, but there can be any characters in s1 in between the sequence.- tnutty2k8 September 22, 2017 in United States
isSpecialSubstring('abcdefg', 'abc') => true
isSpecialSubstring('abcdefg', 'acg') => true
isSpecialSubstring('abcdefg', 'acb') => false;
The first two are abc and acg appears in 'abcdefg' in that order, although there might be multiple chars between the next character in s2.
The last one is false, because in 'acb' the character 'b' appears before the character 'c' in 'abcdefg'
Hope thats clear.
| Report Duplicate | Flag | PURGE
Open Chat in New Window