1346. Check If N and Its Double Exist Easy
1/**
2 * [1346] Check If N and Its Double Exist
3 *
4 * Given an array arr of integers, check if there exist two indices i and j such that :
5 *
6 * i != j
7 * 0 <= i, j < arr.length
8 * arr[i] == 2 * arr[j]
9 *
10 *
11 * <strong class="example">Example 1:
12 *
13 * Input: arr = [10,2,5,3]
14 * Output: true
15 * Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]
16 *
17 * <strong class="example">Example 2:
18 *
19 * Input: arr = [3,1,7,11]
20 * Output: false
21 * Explanation: There is no i and j that satisfy the conditions.
22 *
23 *
24 * Constraints:
25 *
26 * 2 <= arr.length <= 500
27 * -10^3 <= arr[i] <= 10^3
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/check-if-n-and-its-double-exist/
33// discuss: https://leetcode.com/problems/check-if-n-and-its-double-exist/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn check_if_exist(arr: Vec<i32>) -> bool {
39 false
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_1346() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.