sweet1cris

Untitled

Jan 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class Solution {
  2.     /**
  3.      * @param A a string
  4.      * @param B a string
  5.      * @return a boolean
  6.      */
  7.     public boolean stringPermutation(String A, String B) {
  8.         // Write your code here
  9.         int[] cnt = new int[1000];
  10.         for (int i = 0; i < A.length(); ++i)
  11.             cnt[(int)A.charAt(i)] += 1;
  12.         for (int i = 0; i < B.length(); ++i)
  13.             cnt[(int)B.charAt(i)] -= 1;
  14.         for (int i = 0; i < 1000; ++i)
  15.             if (cnt[i] != 0)
  16.                 return false;
  17.         return true;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment