Given two strings, write a method to decide if one is a permutation of the other.
Answers
Answered by
4
Answer_
As mentioned in the comment s1.toCharArray()==s2.toCharArray() is wrong because you are not really comparing values in the array just the references of those 2 newly created arrays. You should sort those arrays Arrays.sort And then use Arrays.equals to compare those arrays.
Answered by
3
Heya,
The METHOD:
Permutation of a string is another string that contains same characters, only the order of characters can be different.
An anagram of a string is another string that contains same characters, only the order of characters can be different.
COMPARE THE TWO TO SEE THE RESULTS...
Similar questions