• + 0 comments
    fun anagram(s: String): Int {
        // Write your code here
        if(s.length % 2 !=0)
            return -1
        var res = 0
        val middle = s.length/2
        var sub1 = s.subSequence(0, middle)
        var sub2 = s.subSequence(middle,s.length)
        var s1 = StringBuilder(sub1)
        var s2 = StringBuilder(sub2)
        for(c in s1){
            if(s2.contains(c)){
                val index = s2.indexOf(c)
                s2.deleteCharAt(index)
            }else
                res++
        }
        return res
    }