| 1 | class Solution |
| 2 | { |
| 3 | int transform (String A, String B) |
| 4 | { |
| 5 | // code here |
| 6 | if(A.length()!=B.length()) return -1; |
| 7 | int arr[] = new int[256]; |
| 8 | for(int i=0;i<A.length();i++) |
| 9 | { |
| 10 | arr[A.charAt(i)]++; |
| 11 | arr[B.charAt(i)]--; |
| 12 | } |
| 13 | |
| 14 | for(int i=0;i<256;i++) |
| 15 | { |
| 16 | if(arr[i]!=0) return -1; |
| 17 | } |
| 18 | |
| 19 | int res=0; |
| 20 | int p1 = A.length()-1; |
| 21 | int p2 = B.length()-1; |
| 22 | |
| 23 | while(p1>=0) |
| 24 | { |
| 25 | if(A.charAt(p1)!=B.charAt(p2)) |
| 26 | { |
| 27 | res++; |
| 28 | } |
| 29 | else |
| 30 | { |
| 31 | p2--; |
| 32 | } |
| 33 | p1--; |
| 34 | } |
| 35 | return res; |
| 36 | } |
| 37 | } |
nothing calls this directly
no outgoing calls
no test coverage detected