This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2018-05-09T20:47:08.023Z","extensionVersion":"v2.9.2"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Find first duplicate integer in vector. | |
/// | |
/// Assumed that array a contains only number in range [1, a.len()]. | |
/// O(n) time complexity and O(1) memory. NOT PURE FUNCTIONAL. | |
/// | |
/// # Example | |
/// | |
/// ``` | |
/// assert!(first_duplicate(vec![8, 4, 6, 2, 6, 4, 7, 9, 5, 8]) == 6); | |
/// assert!(first_duplicate(vec![2, 1, 4, 5, 3]) == -1); |