File tree 3 files changed +55
-0
lines changed
solution/1300-1399/1346.Check If N and Its Double Exist
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -441,6 +441,26 @@ impl Solution {
441
441
}
442
442
```
443
443
444
+ ### ** PHP**
445
+
446
+ ``` php
447
+ class Solution {
448
+ /**
449
+ * @param Integer[] $arr
450
+ * @return Boolean
451
+ */
452
+ function checkIfExist($arr) {
453
+ for ($i = 0; $i < count($arr); $i++) {
454
+ $hashtable[$arr[$i] * 2] = $i;
455
+ }
456
+ for ($i = 0; $i < count($arr); $i++) {
457
+ if (isset($hashtable[$arr[$i]]) && $hashtable[$arr[$i]] != $i) return true;
458
+ }
459
+ return false;
460
+ }
461
+ }
462
+ ```
463
+
444
464
### ** ...**
445
465
446
466
```
Original file line number Diff line number Diff line change @@ -407,6 +407,26 @@ impl Solution {
407
407
}
408
408
```
409
409
410
+ ### ** PHP**
411
+
412
+ ``` php
413
+ class Solution {
414
+ /**
415
+ * @param Integer[] $arr
416
+ * @return Boolean
417
+ */
418
+ function checkIfExist($arr) {
419
+ for ($i = 0; $i < count($arr); $i++) {
420
+ $hashtable[$arr[$i] * 2] = $i;
421
+ }
422
+ for ($i = 0; $i < count($arr); $i++) {
423
+ if (isset($hashtable[$arr[$i]]) && $hashtable[$arr[$i]] != $i) return true;
424
+ }
425
+ return false;
426
+ }
427
+ }
428
+ ```
429
+
410
430
### ** ...**
411
431
412
432
```
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ /**
3
+ * @param Integer[] $arr
4
+ * @return Boolean
5
+ */
6
+ function checkIfExist ($arr ) {
7
+ for ($i = 0 ; $i < count ($arr ); $i ++ ) {
8
+ $hashtable [$arr [$i ] * 2 ] = $i ;
9
+ }
10
+ for ($i = 0 ; $i < count ($arr ); $i ++ ) {
11
+ if (isset ($hashtable [$arr [$i ]]) && $hashtable [$arr [$i ]] != $i ) return true ;
12
+ }
13
+ return false ;
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments