1054. Distant Barcodes Medium

@problem@discussion
#Array#Hash Table#Greedy#Sorting#Heap (Priority Queue)#Counting



1/**
2 * [1054] Distant Barcodes
3 *
4 * In a warehouse, there is a row of barcodes, where the i^th barcode is barcodes[i].
5 * Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.
6 *  
7 * Example 1:
8 * Input: barcodes = [1,1,1,2,2,2]
9 * Output: [2,1,2,1,2,1]
10 * Example 2:
11 * Input: barcodes = [1,1,1,1,2,2,3,3]
12 * Output: [1,3,1,3,1,2,1,2]
13 *  
14 * Constraints:
15 * 
16 * 	1 <= barcodes.length <= 10000
17 * 	1 <= barcodes[i] <= 10000
18 * 
19 */
20pub struct Solution {}
21
22// problem: https://leetcode.com/problems/distant-barcodes/
23// discuss: https://leetcode.com/problems/distant-barcodes/discuss/?currentPage=1&orderBy=most_votes&query=
24
25// submission codes start here
26
27impl Solution {
28    pub fn rearrange_barcodes(barcodes: Vec<i32>) -> Vec<i32> {
29        vec![]
30    }
31}
32
33// submission codes end
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_1054() {
41    }
42}
43


Back
© 2025 bowen.ge All Rights Reserved.