Skip to content

Commit 407636d

Browse files
committed
Merge branch 'main' of github.com:tkzzzzzz6/Algorithm_beginner_learning_notes
2 parents 9341abe + 6b0273c commit 407636d

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# @lc app=leetcode.cn id=3093 lang=python3
3+
# @lcpr version=30204
4+
#
5+
# [3093] 最长公共后缀查询
6+
#
7+
8+
9+
# @lcpr-template-start
10+
11+
# @lcpr-template-end
12+
# @lc code=start
13+
class Solution:
14+
def stringIndices(self, wordsContainer: List[str], wordsQuery: List[str]) -> List[int]:
15+
16+
# @lc code=end
17+
18+
19+
20+
#
21+
# @lcpr case=start
22+
# ["abcd","bcd","xbcd"]\n["cd","bcd","xyz"]\n
23+
# @lcpr case=end
24+
25+
# @lcpr case=start
26+
# ["abcdefgh","poiuygh","ghghgh"]\n["gh","acbfgh","acbfegh"]\n
27+
# @lcpr case=end
28+
29+
#
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# @lc app=leetcode.cn id=3121 lang=python3
3+
# @lcpr version=30204
4+
#
5+
# [3121] 统计特殊字母的数量 II
6+
#
7+
8+
9+
# @lcpr-template-start
10+
11+
# @lcpr-template-end
12+
# @lc code=start
13+
class Solution:
14+
def numberOfSpecialChars(self, word: str) -> int:
15+
ans = 0
16+
state = [0]*27
17+
for c in map(ord,word):
18+
x = c & 31
19+
if c & 32:
20+
if state[x] == 0:
21+
state[x] = 1
22+
elif state[x] == 2:
23+
state[x] = -1
24+
ans -=1
25+
else:
26+
if state[x] == 0:
27+
state[x] = -1
28+
elif state[x] == 1:
29+
state[x] =2
30+
ans+=1
31+
32+
return ans
33+
34+
# @lc code=end
35+
36+
37+
38+
#
39+
# @lcpr case=start
40+
# "aaAbcBC"\n
41+
# @lcpr case=end
42+
43+
# @lcpr case=start
44+
# "abc"\n
45+
# @lcpr case=end
46+
47+
# @lcpr case=start
48+
# "AbBCab"\n
49+
# @lcpr case=end
50+
51+
#

0 commit comments

Comments
 (0)