Checking if two strings are permutations of each other

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

How to determine if two strings are permutations of each other

30条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 09:09

    public class TwoStrgPermutation {
    
    public int checkForUnique(String s1, String s2)
    {
        int[] array1 = new int[256];
        int[] array2 = new int[256];
    
        array1 = arrayStringCounter(array1,s1);
        array2 = arrayStringCounter(array2,s2);
    
        if(Arrays.equals(array1, array2))
            return 0;
        else
            return 1;
    }
    
    public int[] arrayStringCounter(int[] array,String s)
    {
        int val;
        for(int i=0;i0)
                {
                    System.out.println("no it is not");
                }
            }
            else
            {
                System.out.println("no it is not");
            }
    
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
    }
    
    }
    

提交回复
热议问题