Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company
- import java.util.*
- fun main() {
- val sc = Scanner(System.`in`)
- val n = sc.nextInt()
- val number = sc.next()
- val result = minimiseMoves(number, n)
- println(result)
- }
- fun minimiseMoves(number: String, n: Int): Int {
- var moves = 0
- moves += number[n - 1] - '0'
- for (i in 0 until n - 1) {
- if (number[i] != '0')
- moves += number[i] - '0' + 1
- }
- return moves
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement