cbvirtua 1.0.81 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/check_box.svg ADDED
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749568783409" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4227" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M426.005333 725.994667l384-384-60.010667-61.994667-324.010667 324.010667-152-152-60.010667 60.010667zM810.005333 128q36.010667 0 60.992 26.005333t25.002667 60.010667l0 596.010667q0 34.005333-25.002667 60.010667t-60.992 26.005333l-596.010667 0q-36.010667 0-60.992-26.005333t-25.002667-60.010667l0-596.010667q0-34.005333 25.002667-60.010667t60.992-26.005333l596.010667 0z" fill="#222222" p-id="4228"></path></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749569004781" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1551" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M810.005333 128q34.005333 0 60.010667 26.005333t26.005333 60.010667l0 596.010667q0 34.005333-26.005333 60.010667t-60.010667 26.005333l-596.010667 0q-34.005333 0-60.010667-26.005333t-26.005333-60.010667l0-596.010667q0-34.005333 26.005333-60.010667t60.010667-26.005333l596.010667 0zM810.005333 213.994667l-596.010667 0 0 596.010667 596.010667 0 0-596.010667z" fill="#222222" p-id="1552"></path></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749568817715" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4450" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M245.333333 128h533.333334A117.333333 117.333333 0 0 1 896 245.333333v533.333334A117.333333 117.333333 0 0 1 778.666667 896H245.333333A117.333333 117.333333 0 0 1 128 778.666667V245.333333A117.333333 117.333333 0 0 1 245.333333 128z m0 64c-29.44 0-53.333333 23.893333-53.333333 53.333333v533.333334c0 29.44 23.893333 53.333333 53.333333 53.333333h533.333334c29.44 0 53.333333-23.893333 53.333333-53.333333V245.333333c0-29.44-23.893333-53.333333-53.333333-53.333333H245.333333z" p-id="4451"></path></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbvirtua",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,49 @@
1
+ function longestRepeating(s: string, queryCharacters: string, queryIndices: number[]): number[] {
2
+ const n = s.length
3
+ const q = queryIndices.length
4
+ const res = Array(q).fill(1)
5
+
6
+ const odt = new ODT(n, -1) // !珂朵莉树维护区间字符类型
7
+ s.split('').forEach((c, i) => {
8
+ odt.set(i, i + 1, c.charCodeAt(0) - 97)
9
+ })
10
+
11
+ const lens = new SortedList<number>() // !SortedList维护每个连续段的长度
12
+ odt.enumerateAll((start, end, value) => {
13
+ if (value !== -1) {
14
+ lens.add(end - start)
15
+ }
16
+ })
17
+
18
+ for (let i = 0; i < q; i++) {
19
+ const target = queryCharacters.charCodeAt(i) - 97
20
+ const pos = queryIndices[i]
21
+
22
+ // !每次更新最多影响左中右三段区间
23
+ // !先删除这三段区间的长度,修改后,再添加这三段区间的长度
24
+ // 这种做法无需分类讨论
25
+ const [start, end] = odt.get(pos)!
26
+ const leftSeg = odt.get(start - 1)
27
+ const rightSeg = odt.get(end)
28
+ const first = leftSeg ? leftSeg[0] : 0
29
+ const last = rightSeg ? rightSeg[1] : n
30
+ odt.enumerateRange(first, last, (start, end) => {
31
+ lens.discard(end - start)
32
+ })
33
+
34
+ odt.set(pos, pos + 1, target)
35
+
36
+ odt.enumerateRange(first, last, (start, end) => {
37
+ lens.add(end - start)
38
+ })
39
+
40
+ res[i] = lens.max()
41
+ }
42
+
43
+ return res
44
+ }
45
+
46
+ 作者:草莓奶昔🍓
47
+ 链接:https://leetcode.cn/problems/longest-substring-of-one-repeating-character/solutions/2287639/typescript-ke-duo-li-shu-by-981377660lmt-n77n/
48
+ 来源:力扣(LeetCode)
49
+ 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。