Skip to content

Commit 2eabb4f

Browse files
authored
Solution to 1023 (#173)
1 parent e5daa11 commit 2eabb4f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/unresolved/1023.camelcase-matching.jl src/problems/1023.camelcase-matching.jl

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ---
22
# title: 1023. Camelcase Matching
33
# id: problem1023
4-
# author: Tian Jun
5-
# date: 2020-10-31
4+
# author: Pixia1234
5+
# date: 2024-06-29
66
# difficulty: Medium
77
# categories: String, Trie
88
# link: <https://leetcode.com/problems/camelcase-matching/description/>
@@ -64,5 +64,21 @@
6464
## @lc code=start
6565
using LeetCode
6666

67-
## add your code here:
67+
function matches(query, pattern)
68+
i, j = 1, 1
69+
while i <= length(query) && j <= length(pattern)
70+
if query[i] == pattern[j]
71+
j += 1
72+
elseif isuppercase(query[i])
73+
return false
74+
end
75+
i += 1
76+
end
77+
return j > length(pattern) && all(!isuppercase, query[i:end])
78+
end
79+
80+
function camelMatch(queries, pattern)
81+
return [matches(query, pattern) for query in queries]
82+
end
83+
6884
## @lc code=end
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@testset "1023.camelcase-matching.jl" begin
2+
@test camelMatch(("FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"),"FB") == ("1,0,1,1,0")
3+
@test camelMatch(("FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"),"FoBa") == ("1,0,1,0,0")
4+
@test camelMatch(("FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"),"FoBaT") == ("0,1,0,0,0")
5+
end

0 commit comments

Comments
 (0)