LeetCode Entry

2553. Separate the Digits in an Array

11.05.2026 easy 2026 kotlin rust

LIst of numbers to list of digits

2553. Separate the Digits in an Array easy substack youtube

https://dmitrysamoylenko.com/leetcode/

11.05.2026.webp

Join me on Telegram

https://t.me/leetcode_daily_unstoppable/1356

Problem TLDR

LIst of numbers to list of digits

Intuition

Convert to strings or do %10 with LInkedList/ArrayDeque or do the reverse.

Approach

  • Kotlin: joinToString converts numbers to strings
  • Rust: use flat_map or to_string/bytes

Complexity

  • Time complexity: \(O(n)\)

  • Space complexity: \(O(n)\)

Code

    fun separateDigits(n: IntArray) =
        n.joinToString("").map{it-'0'}
    pub fn separate_digits(n: Vec<i32>) -> Vec<i32> {
        n.iter().map(|x|x.to_string()).collect::<String>()
        .bytes().map(|b|(b-b'0') as i32).collect()
    }