Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4e7dd96

Browse files
authored
feat: add php solution to lc problem: No.1287 (doocs#961)
1 parent aab08b2 commit 4e7dd96

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

‎solution/1200-1299/1287.Element Appearing More Than 25% In Sorted Array/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ var findSpecialInteger = function (arr) {
112112
};
113113
```
114114

115+
### **PHP**
116+
117+
```php
118+
class Solution {
119+
/**
120+
* @param Integer[] $arr
121+
* @return Integer
122+
*/
123+
function findSpecialInteger($arr) {
124+
$len = count($arr);
125+
for ($i = 0; $i < $len; $i++) {
126+
if ($arr[$i] == $arr[$i + ($len >> 2)]) return $arr[$i];
127+
}
128+
return -1;
129+
}
130+
}
131+
```
132+
115133
### **...**
116134

117135
```

‎solution/1200-1299/1287.Element Appearing More Than 25% In Sorted Array/README_EN.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,24 @@ var findSpecialInteger = function (arr) {
107107
};
108108
```
109109

110+
### **PHP**
111+
112+
```php
113+
class Solution {
114+
/**
115+
* @param Integer[] $arr
116+
* @return Integer
117+
*/
118+
function findSpecialInteger($arr) {
119+
$len = count($arr);
120+
for ($i = 0; $i < $len; $i++) {
121+
if ($arr[$i] == $arr[$i + ($len >> 2)]) return $arr[$i];
122+
}
123+
return -1;
124+
}
125+
}
126+
```
127+
110128
### **...**
111129

112130
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
/**
3+
* @param Integer[] $arr
4+
* @return Integer
5+
*/
6+
function findSpecialInteger($arr) {
7+
$len = count($arr);
8+
for ($i = 0; $i < $len; $i++) {
9+
if ($arr[$i] == $arr[$i + ($len >> 2)]) return $arr[$i];
10+
}
11+
return -1;
12+
}
13+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /