Mars Exploration

  • + 0 comments

    My Solution in kotlin covering All test cases.

    fun marsExploration(s: String): Int {
        var counter = 0
        val lastIndex = s.length - 1
        for(i in 0..s.length step 3) {
            
            if (i > lastIndex) break
            
            if (s[i] != 'S') counter++
            if (s[i + 1] != 'O') counter++
            if (s[i + 2] != 'S') counter++
        }
    
        return counter
    }