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 957805b

Browse files
committed
day-19
1 parent e01c48e commit 957805b

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
- Day 16: [Odd Even Linked List](https://github.com/libterty/leetcode-challenge/blob/master/src/may/day-sixteen/index.ts) :grin:
2020
- Day 17: [Find All Anagrams in a String Solution](https://github.com/libterty/leetcode-challenge/blob/master/src/may/day-seventeen/index.ts) :hear_no_evil:
2121
- Day 18: [Permutation in String](https://github.com/libterty/leetcode-challenge/blob/master/src/may/day-eighteen/index.ts) :pig_nose:
22+
- Day 19: [Online Stock Span](https://github.com/libterty/leetcode-challenge/blob/master/src/may/day-nighteen/index.ts) :pig_nose:

‎src/lib/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const fn = (): void => {};
2+
const testArr: any[] = ['1', 2, fn()];
3+
4+
const [abc, abc2, abc3] = testArr;
5+
6+
console.log(`abc: `, abc);
7+
console.log(`abc: `, abc2);
8+
console.log(`abc: `, abc3);

‎src/may/day-nineteen/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var StockSpanner = function () {
2+
this.values = [];
3+
};
4+
5+
/**
6+
* @param {number} price
7+
* @return {number}
8+
*/
9+
StockSpanner.prototype.next = function (price: number): number {
10+
let count: number = 1;
11+
12+
while (this.values.legnth > 0 && this.values[this.values.length - 1][0] <= price) {
13+
count += this.values.pop()[1];
14+
}
15+
this.values.push([price, count]);
16+
return count;
17+
};

0 commit comments

Comments
(0)

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