mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-04 03:00:06 +08:00
build
This commit is contained in:
@@ -1068,6 +1068,12 @@ Below is an example code for implementing a stack based on a linked list:
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="linkedlist_stack.rb"
|
||||
[class]{LinkedListStack}-[func]{}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="linkedlist_stack.zig"
|
||||
@@ -1621,10 +1627,7 @@ Since the elements to be pushed onto the stack may continuously increase, we can
|
||||
|
||||
/* 出栈 */
|
||||
fn pop(&mut self) -> Option<T> {
|
||||
match self.stack.pop() {
|
||||
Some(num) => Some(num),
|
||||
None => None,
|
||||
}
|
||||
self.stack.pop()
|
||||
}
|
||||
|
||||
/* 访问栈顶元素 */
|
||||
@@ -1745,6 +1748,12 @@ Since the elements to be pushed onto the stack may continuously increase, we can
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="array_stack.rb"
|
||||
[class]{ArrayStack}-[func]{}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="array_stack.zig"
|
||||
|
||||
Reference in New Issue
Block a user