Write a function (in any language you want) that takes in a string like e.g. "(({{[[]]}}))" and checks if the string is a complete mirror on both sides.
e.g.
[[{{}}]] will return true
{{{{]]]] will return false
Write a function (in any language you want) that takes in a string like e.g. "(({{[[]]}}))" and checks if the string is a complete mirror on both sides.
e.g.
[[{{}}]] will return true
{{{{]]]] will return false
Dude didn't we had this thread before?
then must be easy by now for you, right?
It's called a palindrome you fucking zoomer
A palindrome is a word that reads the same as it goes backwards, if you read [[{{}}]] backwards then you get ]]}}{{[[ so it is not a palindrome, but is a mirror on both sides.
Do your own homework
i just put it into sbcl and see if any unmatched parens found
why yes, I have 168 IQ
Wrote this in notepad so not sure if it runs
public boolean isMirrored(String target) {
char[] characters = target.toCharArray();
if(characters.length % 2 != 0) {
return false;
}
int right = chracters.length-1;
int left = 0;
for(; right > left; i++) {
if(characters[right] != characters[left]) {
return false;
}
}
return true;
}
nevermind, missread the question, total brainlett
Since there is no obvious way of matching mirrored characters, the only solution i can think of is to keep a mapping from left->right and use the same strategy as for palindroms.