US Interview Question for Software Engineers
- -1of 1 vote
AnswersGiven an array of lower case strings, the task is to find the number of strings that are distinct.
- boony August 09, 2018 in United States
Two strings are distinct if they can be made equivalent by performing some operations on one or both string
swapEven : swap a character at an even-numbered index with a character at another even-numbered index
swapOdd : swap a character at an odd-numbered index with a character at another odd-numbered index
Input : arr = {"abcd", "cbad", "bacd"}
Output : 2
The 2nd string can be converted to the 1st by swapping
the first and third characters. So there are 2 distinct
strings as the third string cannot be converted to the
first.
string input[] = {"abcd", "acbd", "adcb", "cdba",
"bcda", "badc"};
ans =4| Report Duplicate | Flag | PURGE
US Software Engineer
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Interview Type: In-Person
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.