Skip to content

Commit 15c9faa

Browse files
committed
整理
Change-Id: I158e2d51efc804fc15545de77a000d2d00473380
1 parent a5d87da commit 15c9faa

File tree

4 files changed

+175
-2
lines changed

4 files changed

+175
-2
lines changed

go/leetcode/208.实现-trie-前缀树.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package leetcode
1+
// package leetcode
22

33
/*
44
* @lc app=leetcode.cn id=208 lang=golang

go/leetcode/225.用队列实现栈.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package leetcode
1+
// package leetcode
22

33
/*
44
* @lc app=leetcode.cn id=225 lang=golang

go/leetcode/232.用栈实现队列.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* @lc app=leetcode.cn id=232 lang=golang
3+
*
4+
* [232] 用栈实现队列
5+
*
6+
* https://leetcode-cn.com/problems/implement-queue-using-stacks/description/
7+
*
8+
* algorithms
9+
* Easy (61.02%)
10+
* Likes: 95
11+
* Dislikes: 0
12+
* Total Accepted: 20.3K
13+
* Total Submissions: 33.2K
14+
* Testcase Example: '["MyQueue","push","push","peek","pop","empty"]\n[[],[1],[2],[],[],[]]'
15+
*
16+
* 使用栈实现队列的下列操作:
17+
*
18+
*
19+
* push(x) -- 将一个元素放入队列的尾部。
20+
* pop() -- 从队列首部移除元素。
21+
* peek() -- 返回队列首部的元素。
22+
* empty() -- 返回队列是否为空。
23+
*
24+
*
25+
* 示例:
26+
*
27+
* MyQueue queue = new MyQueue();
28+
*
29+
* queue.push(1);
30+
* queue.push(2);
31+
* queue.peek(); // 返回 1
32+
* queue.pop(); // 返回 1
33+
* queue.empty(); // 返回 false
34+
*
35+
* 说明:
36+
*
37+
*
38+
* 你只能使用标准的栈操作 -- 也就是只有 push to top, peek/pop from top, size, 和 is empty
39+
* 操作是合法的。
40+
* 你所使用的语言也许不支持栈。你可以使用 list 或者 deque(双端队列)来模拟一个栈,只要是标准的栈操作即可。
41+
* 假设所有操作都是有效的 (例如,一个空的队列不会调用 pop 或者 peek 操作)。
42+
*
43+
*
44+
*/
45+
type MyQueue struct {
46+
47+
}
48+
49+
50+
/** Initialize your data structure here. */
51+
func Constructor() MyQueue {
52+
53+
}
54+
55+
56+
/** Push element x to the back of queue. */
57+
func (this *MyQueue) Push(x int) {
58+
59+
}
60+
61+
62+
/** Removes the element from in front of queue and returns that element. */
63+
func (this *MyQueue) Pop() int {
64+
65+
}
66+
67+
68+
/** Get the front element. */
69+
func (this *MyQueue) Peek() int {
70+
71+
}
72+
73+
74+
/** Returns whether the queue is empty. */
75+
func (this *MyQueue) Empty() bool {
76+
77+
}
78+
79+
80+
/**
81+
* Your MyQueue object will be instantiated and called as such:
82+
* obj := Constructor();
83+
* obj.Push(x);
84+
* param_2 := obj.Pop();
85+
* param_3 := obj.Peek();
86+
* param_4 := obj.Empty();
87+
*/
88+

go/leetcode/44.通配符匹配.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* @lc app=leetcode.cn id=44 lang=golang
3+
*
4+
* [44] 通配符匹配
5+
*
6+
* https://leetcode-cn.com/problems/wildcard-matching/description/
7+
*
8+
* algorithms
9+
* Hard (25.03%)
10+
* Likes: 195
11+
* Dislikes: 0
12+
* Total Accepted: 11.1K
13+
* Total Submissions: 44.3K
14+
* Testcase Example: '"aa"\n"a"'
15+
*
16+
* 给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配。
17+
*
18+
* '?' 可以匹配任何单个字符。
19+
* '*' 可以匹配任意字符串(包括空字符串)。
20+
*
21+
*
22+
* 两个字符串完全匹配才算匹配成功。
23+
*
24+
* 说明:
25+
*
26+
*
27+
* s 可能为空,且只包含从 a-z 的小写字母。
28+
* p 可能为空,且只包含从 a-z 的小写字母,以及字符 ? 和 *。
29+
*
30+
*
31+
* 示例 1:
32+
*
33+
* 输入:
34+
* s = "aa"
35+
* p = "a"
36+
* 输出: false
37+
* 解释: "a" 无法匹配 "aa" 整个字符串。
38+
*
39+
* 示例 2:
40+
*
41+
* 输入:
42+
* s = "aa"
43+
* p = "*"
44+
* 输出: true
45+
* 解释: '*' 可以匹配任意字符串。
46+
*
47+
*
48+
* 示例 3:
49+
*
50+
* 输入:
51+
* s = "cb"
52+
* p = "?a"
53+
* 输出: false
54+
* 解释: '?' 可以匹配 'c', 但第二个 'a' 无法匹配 'b'。
55+
*
56+
*
57+
* 示例 4:
58+
*
59+
* 输入:
60+
* s = "adceb"
61+
* p = "*a*b"
62+
* 输出: true
63+
* 解释: 第一个 '*' 可以匹配空字符串, 第二个 '*' 可以匹配字符串 "dce".
64+
*
65+
*
66+
* 示例 5:
67+
*
68+
* 输入:
69+
* s = "acdcb"
70+
* p = "a*c?b"
71+
* 输入: false
72+
*
73+
*/
74+
75+
import (
76+
"strings"
77+
)
78+
// 各种case区别处理
79+
// 分为普通字符和通配符两种,遇到?则s跳过一个,遇到*则p跳过看后面是否匹配
80+
const w byte = '*'
81+
const c byte = '?'
82+
func isMatch(s string, p string) bool {
83+
84+
}
85+

0 commit comments

Comments
 (0)