• + 0 comments

    *Hi , I have done the problem through the following code. Can anyone explain me where I commited the mistake *

    I appreciate your help

    thanks in advance

      	fun biggerIsGreater(w: String): String {
        for (i in w.length-1 downTo 1){
            for( j in i-1 downTo 0){
                if(w[i]>w[j]){
                    val result = w.toCharArray()
                    val temp = result[i]
                    result[i]=result[j]
                    result[j]=temp
                    return  String(result).substring(0,j+1) + String(result).substring(j+1,w.length).reversed()
                }
            }
        }    
        return "no answer"
    
    }