<commit_before>// https://leetcode.com/problems/intervals-between-identical-elements/
pub fn get_distances(arr: Vec<i32>) -> Vec<i64> {
    todo!()
}

fn main() {
    println!("{}", get_distances(vec![2, 1, 3, 1, 2, 3, 3])); // [4,2,7,2,4,4,5]
    println!("{}", get_distances(vec![10, 5, 10, 10])); // [5,0,3,4]
}<commit_msg>Update problem 2121<commit_after>use std::collections::HashMap;

// https://leetcode.com/problems/intervals-between-identical-elements/
pub fn get_distances(arr: Vec<i32>) -> Vec<i64> {
    let mut map: HashMap<i32, Vec<usize>> = HashMap::new();
    for (i, num) in arr.iter().enumerate() {
        map.entry(*num).or_insert(vec![]).push(i);
    }
    let mut answer = vec![0; arr.len()];
    for (i, num) in arr.iter().enumerate() {
        let mut sum: i64 = 0;
        for j in map[num].iter() {
            if i == *j {
                continue;
            }
            sum += i64::abs(i as i64 - *j as i64)
        }
        answer[i] = sum;
    }
    answer
}

fn main() {
    println!("{:?}", get_distances(vec![2, 1, 3, 1, 2, 3, 3])); // [4,2,7,2,4,4,5]
    println!("{:?}", get_distances(vec![10, 5, 10, 10])); // [5,0,3,4]
}
{'fraction_non_alphanumeric': 0.22805507745266781, 'fraction_numerical': 0.06368330464716007, 'mean_word_length': 2.739549839228296, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4211873', 'n_tokens_mistral': 506, 'n_tokens_neox': 467, 'n_words': 97}