Skip to content

Commit c290d32

Browse files
authored
feat: add php solution to lc problem: No.1346 (doocs#993)
1 parent 87be8a0 commit c290d32

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

solution/1300-1399/1346.Check If N and Its Double Exist/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,26 @@ impl Solution {
441441
}
442442
```
443443

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+
444464
### **...**
445465

446466
```

solution/1300-1399/1346.Check If N and Its Double Exist/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,26 @@ impl Solution {
407407
}
408408
```
409409

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+
410430
### **...**
411431

412432
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}

0 commit comments

Comments
 (0)