LeetCode - Algorithms - 1346. Check If N and Its Double Exist

Problem

1346. Check If N and Its Double Exist

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class Solution {
public bool CheckIfExist(int[] arr) {
bool existed = false;
for(int i = 0; i < arr.Length; i++) {
for(int j = 0; j != i && j < arr.Length; j++) {
if (arr[i]==2*arr[j] || arr[i]*2==arr[j]) {
existed = true;
break;
}
}
}
return existed;
}
}

Submission Detail

  • Accepted
  • Runtime 105 ms, Beats 80.20%
  • Memory 41 MB, Beats 14.60%