File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed
solution/1300-1399/1394.Find Lucky Integer in an Array Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,28 @@ func findLucky(arr []int) int {
139
139
}
140
140
```
141
141
142
+ ### ** PHP**
143
+
144
+ ``` php
145
+ class Solution {
146
+ /**
147
+ * @param Integer[] $arr
148
+ * @return Integer
149
+ */
150
+ function findLucky($arr) {
151
+ $max = -1;
152
+ for ($i = 0; $i < count($arr); $i++) {
153
+ $hashtable[$arr[$i]] += 1;
154
+ }
155
+ $keys = array_keys($hashtable);
156
+ for ($j = 0; $j < count($keys); $j++) {
157
+ if ($hashtable[$keys[$j]] == $keys[$j]) $max = max($max, $keys[$j]);
158
+ }
159
+ return $max;
160
+ }
161
+ }
162
+ ```
163
+
142
164
### ** ...**
143
165
144
166
```
Original file line number Diff line number Diff line change @@ -115,6 +115,28 @@ func findLucky(arr []int) int {
115
115
}
116
116
```
117
117
118
+ ### ** PHP**
119
+
120
+ ``` php
121
+ class Solution {
122
+ /**
123
+ * @param Integer[] $arr
124
+ * @return Integer
125
+ */
126
+ function findLucky($arr) {
127
+ $max = -1;
128
+ for ($i = 0; $i < count($arr); $i++) {
129
+ $hashtable[$arr[$i]] += 1;
130
+ }
131
+ $keys = array_keys($hashtable);
132
+ for ($j = 0; $j < count($keys); $j++) {
133
+ if ($hashtable[$keys[$j]] == $keys[$j]) $max = max($max, $keys[$j]);
134
+ }
135
+ return $max;
136
+ }
137
+ }
138
+ ```
139
+
118
140
### ** ...**
119
141
120
142
```
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ /**
3
+ * @param Integer[] $arr
4
+ * @return Integer
5
+ */
6
+ function findLucky ($arr ) {
7
+ $max = - 1 ;
8
+ for ($i = 0 ; $i < count ($arr ); $i ++ ) {
9
+ $hashtable [$arr [$i ]] += 1 ;
10
+ }
11
+ $keys = array_keys ($hashtable );
12
+ for ($j = 0 ; $j < count ($keys ); $j ++ ) {
13
+ if ($hashtable [$keys [$j ]] == $keys [$j ]) $max = max ($max , $keys [$j ]);
14
+ }
15
+ return $max ;
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments