LeetCode Entry
3483. Unique 3-Digit Even Numbers
digit evens consisting of given digits
3483. Unique 3-Digit Even Numbers easy substack youtube
https://dmitrysamoylenko.com/leetcode/

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/1479
Problem TLDR
3-digit evens consisting of given digits
Intuition
Brute-force either range 100..999 or all the 720 permutations of 3 out of 10
Approach
- Kotlin: remove does remove a single instance and returns true/false
- Rust: itertools has permutations
Complexity
-
Time complexity: \(O(1)\)
-
Space complexity: \(O(1)\)
Code
fun totalNumbers(d: IntArray) =
(50..499).count{"${it*2}".map{it-'0'}.all(d.toMutableList()::remove)}
pub fn total_numbers(d: Vec<i32>) -> i32 {
d.iter().permutations(3).filter(|v| v[0] > &0 && v[2] % 2 < 1).unique().count() as _
}
Comments