07.12.2023
1903. Largest Odd Number in String easy
blog post
Join me on Telegram
https://t.me/leetcode_daily_unstoppable/431
Intuition
Just search for the last odd
Approach
Let’s write Kotlin one-liner
Complexity
Time complexity:
O(n)Space complexity:
O(n)
Code
fun largestOddNumber(num: String): String =
num.dropLastWhile { it.toInt() % 2 == 0 }