Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shihabmridha/leetcode
My leetcode solutions
https://github.com/shihabmridha/leetcode
go golang leetcode
Last synced: 4 days ago
JSON representation
My leetcode solutions
- Host: GitHub
- URL: https://github.com/shihabmridha/leetcode
- Owner: shihabmridha
- Created: 2022-08-17T22:08:07.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-24T17:22:18.000Z (8 months ago)
- Last Synced: 2024-11-09T21:07:55.454Z (2 months ago)
- Topics: go, golang, leetcode
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Template
```
package mainimport (
"bufio"
"fmt"
"os"
)var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }func main() {
defer writer.Flush()
}```
### Usage
I create a new directory with the problem number and problem name using the following format `{problem_number}_{problem_name}`. Create a file named `{problem_number}`. I create a `test` for each problem to test the code.### Helpers
- Use `%v` to print array. Example: `fmt.Printf("%v", projects)`
- Create empty map `make(map[int]int)`, `map[rune]bool{}`
- Create empty rune `make([]rune, 5) // with size`, `map[rune]bool{}`
- Sort list/slice `slices.Sort(mySlice)`.
- Sort with comparer `sort.Slice(mySlice, func(i, j int) bool { return mySlice[i] > mySlice[j] })`
- Deep compare array `reflect.DeepEqual([]int{0, 1, 1}, []int{0, 1, 1})`