Skip to content

Commit 781602e

Browse files
authored
Update README_EN.md
1 parent 2c8e61a commit 781602e

File tree

1 file changed

+13
-4
lines changed
  • solution/0700-0799/0703.Kth Largest Element in a Stream

1 file changed

+13
-4
lines changed

solution/0700-0799/0703.Kth Largest Element in a Stream/README_EN.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,34 @@ class MinHeap {
351351
#### TypeScript
352352

353353
```ts
354-
export class KthLargest {
354+
class KthLargest {
355355
#pq = new MinPriorityQueue();
356356
#k = 0;
357357

358358
constructor(k: number, nums: number[]) {
359359
this.#k = k;
360360
for (const x of nums) {
361361
this.#pq.enqueue(x);
362-
if (this.#pq.size() > k) this.#pq.dequeue();
362+
if (this.#pq.size() > k) {
363+
this.#pq.dequeue();
364+
}
363365
}
364366
}
365367

366368
add(val: number): number {
367369
this.#pq.enqueue(val);
368-
if (this.#pq.size() > this.#k) this.#pq.dequeue();
369-
370+
if (this.#pq.size() > this.#k) {
371+
this.#pq.dequeue();
372+
}
370373
return this.#pq.front().element;
371374
}
372375
}
376+
377+
/**
378+
* Your KthLargest object will be instantiated and called as such:
379+
* var obj = new KthLargest(k, nums)
380+
* var param_1 = obj.add(val)
381+
*/
373382
```
374383

375384
<!-- tabs:end -->

0 commit comments

Comments
 (0)