boony
BAN USERtow string are said to be twins only if they can be made equivalent by performing some operations on one or both string.
there are two possible operations:
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
fore exemple :
given : arr ["cdab","dcba","a]
- -1of 1 vote
Answerswrite a JSON validator
- boony in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 4 votes
AnswersGiven an array of lower case strings, the task is to find the number of strings that are special equivalent.
- boony in United States
Two strings are special equivalent 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
Facebook Software Engineer - -1of 1 vote
AnswersGiven an array of lower case strings, the task is to find the number of strings that are distinct.
- boony 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