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 2e210c8

Browse files
authored
feat: add js solution to lc problem: No.1475 (#1025)
1 parent a6160a3 commit 2e210c8

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,26 @@ class Solution {
392392
}
393393
```
394394

395+
### **JavaScript**
396+
397+
```js
398+
/**
399+
* @param {number[]} prices
400+
* @return {number[]}
401+
*/
402+
var finalPrices = function (prices) {
403+
for (let i = 0; i < prices.length; i++) {
404+
for (let j = i + 1; j < prices.length; j++) {
405+
if (prices[i] >= prices[j]) {
406+
prices[i] -= prices[j];
407+
break;
408+
}
409+
}
410+
}
411+
return prices;
412+
};
413+
```
414+
395415
### **...**
396416

397417
```

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,26 @@ class Solution {
363363
}
364364
```
365365

366+
### **JavaScript**
367+
368+
```js
369+
/**
370+
* @param {number[]} prices
371+
* @return {number[]}
372+
*/
373+
var finalPrices = function (prices) {
374+
for (let i = 0; i < prices.length; i++) {
375+
for (let j = i + 1; j < prices.length; j++) {
376+
if (prices[i] >= prices[j]) {
377+
prices[i] -= prices[j];
378+
break;
379+
}
380+
}
381+
}
382+
return prices;
383+
};
384+
```
385+
366386
### **...**
367387

368388
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} prices
3+
* @return {number[]}
4+
*/
5+
var finalPrices = function (prices) {
6+
for (let i = 0; i < prices.length; i++) {
7+
for (let j = i + 1; j < prices.length; j++) {
8+
if (prices[i] >= prices[j]) {
9+
prices[i] -= prices[j];
10+
break;
11+
}
12+
}
13+
}
14+
return prices;
15+
};

0 commit comments

Comments
(0)

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