Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 코딩테스트
- rnn
- DeepLearning
- torchserve
- NaverAItech
- FDS
- 알고리즘
- leetcode
- datascience
- GCP
- Kubernetes
- 프로그래머스
- python
- GitHub Action
- vscode
- wandb
- NLP
- 네이버AItech
- pep8
- 완전탐색
- PytorchLightning
- github
- GIT
- FastAPI
- Matplotlib
- autoencoder
- 백준
- pytorch
- docker
- Kaggle
Archives
- Today
- Total
Sangmun
Go stack 자료구조 본문
package main
import ("fmt")
type Stack struct {
data []int
}
func (s *Stack) Push(x int) {
s.data = append(s.data, x)
}
func (s *Stack) Pop() int {
if len(s.data) == 0 {
return -1
}
x := s.data[len(s.data)-1]
s.data = s.data[:len(s.data)-1]
return x
}
func (s *Stack) Size() int {
return len(s.data)
}
func (s *Stack) IsEmpty() int {
if len(s.data) == 0 {
return 1
}
return 0
}
func (s *Stack) Top() int {
if len(s.data) == 0 {
return -1
}
return s.data[len(s.data)-1]
}
func main() {
stack := Stack{}
}
Comments