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 97e9c32

Browse files
authored
feat: add php solution to lc problem: No.1475 (#1021)
1 parent 887868c commit 97e9c32

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

‎solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,28 @@ impl Solution {
370370
}
371371
```
372372

373+
### **PHP**
374+
375+
```php
376+
class Solution {
377+
/**
378+
* @param Integer[] $prices
379+
* @return Integer[]
380+
*/
381+
function finalPrices($prices) {
382+
for ($i = 0; $i < count($prices); $i++) {
383+
for ($j = $i + 1; $j < count($prices); $j++) {
384+
if ($prices[$i] >= $prices[$j]) {
385+
$prices[$i] -= $prices[$j];
386+
break;
387+
}
388+
}
389+
}
390+
return $prices;
391+
}
392+
}
393+
```
394+
373395
### **...**
374396

375397
```

‎solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README_EN.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,28 @@ impl Solution {
341341
}
342342
```
343343

344+
### **PHP**
345+
346+
```php
347+
class Solution {
348+
/**
349+
* @param Integer[] $prices
350+
* @return Integer[]
351+
*/
352+
function finalPrices($prices) {
353+
for ($i = 0; $i < count($prices); $i++) {
354+
for ($j = $i + 1; $j < count($prices); $j++) {
355+
if ($prices[$i] >= $prices[$j]) {
356+
$prices[$i] -= $prices[$j];
357+
break;
358+
}
359+
}
360+
}
361+
return $prices;
362+
}
363+
}
364+
```
365+
344366
### **...**
345367

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

0 commit comments

Comments
(0)

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