3270. Find the Key of the Numbers Easy

@problem@discussion
#Math



1/**
2 * [3270] Find the Key of the Numbers
3 *
4 * You are given three positive integers num1, num2, and num3.
5 * The key of num1, num2, and num3 is defined as a four-digit number such that:
6 * 
7 * 	Initially, if any number has less than four digits, it is padded with leading zeros.
8 * 	The i^th digit (1 <= i <= 4) of the key is generated by taking the smallest digit among the i^th digits of num1, num2, and num3.
9 * 
10 * Return the key of the three numbers without leading zeros (if any).
11 *  
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">num1 = 1, num2 = 10, num3 = 1000</span>
15 * Output: <span class="example-io">0</span>
16 * Explanation:
17 * On padding, num1 becomes "0001", num2 becomes "0010", and num3 remains "1000".
18 * 
19 * 	The 1^st digit of the key is min(0, 0, 1).
20 * 	The 2^nd digit of the key is min(0, 0, 0).
21 * 	The 3^rd digit of the key is min(0, 1, 0).
22 * 	The 4^th digit of the key is min(1, 0, 0).
23 * 
24 * Hence, the key is "0000", i.e. 0.
25 * </div>
26 * <strong class="example">Example 2:
27 * <div class="example-block">
28 * Input: <span class="example-io">num1 = 987, num2 = 879, num3 = 798</span>
29 * Output: <span class="example-io">777</span>
30 * </div>
31 * <strong class="example">Example 3:
32 * <div class="example-block">
33 * Input: <span class="example-io">num1 = 1, num2 = 2, num3 = 3</span>
34 * Output: <span class="example-io">1</span>
35 * </div>
36 *  
37 * Constraints:
38 * 
39 * 	1 <= num1, num2, num3 <= 9999
40 * 
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/find-the-key-of-the-numbers/
45// discuss: https://leetcode.com/problems/find-the-key-of-the-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50    pub fn generate_key(num1: i32, num2: i32, num3: i32) -> i32 {
51        0
52    }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_3270() {
63    }
64}
65


Back
© 2025 bowen.ge All Rights Reserved.