Advertisement
md5kafka

Untitled

Oct 3rd, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. class Solution {
  2.     public boolean isAnagram(String s, String t) {
  3.         int[] charCount = new int[256];
  4.         for(char a: s.toCharArray()) {
  5.             charCount[a]++;
  6.         }
  7.         for(char a:t.toCharArray()) {
  8.             charCount[a]--;
  9.         }
  10.         for(int i:charCount) {
  11.             if (i!=0) {
  12.                 return false;
  13.             }
  14.         }
  15.         return true;
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement