deno.land / x / masx200_leetcode_test@10.6.5 / iterator-for-combination / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { combinations } from "../deps.ts";
class CombinationIterator { #res: IteratorResult<string[]>; #gen: Generator<string[]>; constructor(characters: string, combinationLength: number) { this.#gen = combinations(characters, combinationLength); this.#res = this.#gen.next(); }
next(): string { if (this.#res.done) { return ""; } const value = this.#res.value; this.#res = this.#gen.next(); return value.join(""); }
hasNext(): boolean { if (this.#res.done) { return false; } return true; }}export default CombinationIterator;
masx200_leetcode_test

Version Info

Tagged at
a year ago