Checking if two strings are permutations of each other

前端 未结 30 1005
感情败类
感情败类 2020-12-05 08:19

How to determine if two strings are permutations of each other

30条回答
  •  离开以前
    2020-12-05 09:07

    public boolean permitation(String s,String t){
          if(s.length() != t.length()){
              return false;
              }
    
           int[] letters = new int[256];//Assumes that the character set is ASCII
           char[] s_array = s.toCharArray();
    
           for(char c:s_array){         /////count number of each char in s
                 letters[c]++;
            }
           for(int i=0;i

提交回复
热议问题