alex
BAN USER
I very good and talented programmer
- -1of 1 vote
AnswersGiven two string check if they can be made equivalent by performing some operations on one or both string.
- alex in United States
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
Given : s="cdab" , x="abcd"
s -> cdab ->swap a and c ->adcb (swapEven)-> swap b and d (swapOdd) -> s="abcd" = x="abcd"
Given: s="dcba" , x="abcd"
no amount of operation will move character from an odd index to even index, so the two string will never be equals
Given: s="abcd" ,x="abcdcd"
x length to big so will never be equals| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersThe wildcard regex can include the characters * and + .
- alex in United States
‘+’ – matches any single character or empty character!
‘*’ – Matches any sequence of characters (including the empty sequence) For example,
Text = "baaabab":
regex = "ba*a++", output : true
regex = "ba*a+", output : true
regex = "a*ab", output : false
//empty string
Text=""
Regex= "+" , output : true| Report Duplicate | Flag | PURGE
Google Software Engineer Dynamic Programming
- alex August 04, 2019