chore: add package level comments
This commit is contained in:
parent
cc87c4b30c
commit
ee1868a10e
303 changed files with 303 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
// Package q1 implements a solution for https://leetcode.com/problems/two-sum/
|
||||
package q1
|
||||
|
||||
import "slices"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q12 implements a solution for https://leetcode.com/problems/integer-to-roman/
|
||||
package q12
|
||||
|
||||
import "strings"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q13 implements a solution for https://leetcode.com/problems/roman-to-integer/
|
||||
package q13
|
||||
|
||||
func lookup(b byte) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q14 implements a solution for https://leetcode.com/problems/longest-common-prefix/
|
||||
package q14
|
||||
|
||||
func longestCommonPrefix(strs []string) string {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q15 implements a solution for https://leetcode.com/problems/3sum/
|
||||
package q15
|
||||
|
||||
import "slices"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q17 implements a solution for https://leetcode.com/problems/letter-combinations-of-a-phone-number/
|
||||
package q17
|
||||
|
||||
var alphabets = [][]byte{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q19 implements a solution for https://leetcode.com/problems/remove-nth-node-from-end-of-list/
|
||||
package q19
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q2 implements a solution for https://leetcode.com/problems/add-two-numbers/
|
||||
package q2
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q20 implements a solution for https://leetcode.com/problems/valid-parentheses/
|
||||
package q20
|
||||
|
||||
func isValid(s string) bool {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q21 implements a solution for https://leetcode.com/problems/merge-two-sorted-lists/
|
||||
package q21
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q22 implements a solution for https://leetcode.com/problems/generate-parentheses/
|
||||
package q22
|
||||
|
||||
func gen(n, lvl, used int, buf []byte, ret []string) []string {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q23 implements a solution for https://leetcode.com/problems/merge-k-sorted-lists/
|
||||
package q23
|
||||
|
||||
import "container/heap"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q25 implements a solution for https://leetcode.com/problems/reverse-nodes-in-k-group/
|
||||
package q25
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q28 implements a solution for https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/
|
||||
package q28
|
||||
|
||||
import "strings"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q3 implements a solution for https://leetcode.com/problems/longest-substring-without-repeating-characters/
|
||||
package q3
|
||||
|
||||
func lengthOfLongestSubstring(s string) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q33 implements a solution for https://leetcode.com/problems/search-in-rotated-sorted-array/
|
||||
package q33
|
||||
|
||||
func findK(nums []int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q34 implements a solution for https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
|
||||
package q34
|
||||
|
||||
func find(nums []int, target int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q35 implements a solution for https://leetcode.com/problems/search-insert-position/
|
||||
package q35
|
||||
|
||||
func searchInsert(nums []int, target int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q36 implements a solution for https://leetcode.com/problems/valid-sudoku/
|
||||
package q36
|
||||
|
||||
func validateCol(board [][]byte, col int) bool {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q39 implements a solution for https://leetcode.com/problems/combination-sum/
|
||||
package q39
|
||||
|
||||
import "slices"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q4 implements a solution for https://leetcode.com/problems/median-of-two-sorted-arrays/
|
||||
package q4
|
||||
|
||||
import "math"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q42 implements a solution for https://leetcode.com/problems/trapping-rain-water/
|
||||
package q42
|
||||
|
||||
func trap(height []int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q43 implements a solution for https://leetcode.com/problems/multiply-strings/
|
||||
package q43
|
||||
|
||||
import "slices"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q46 implements a solution for https://leetcode.com/problems/permutations/
|
||||
package q46
|
||||
|
||||
func recurse(nums []int, offset int, buf []int, seen []bool, ret [][]int) [][]int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q48 implements a solution for https://leetcode.com/problems/rotate-image/
|
||||
package q48
|
||||
|
||||
func rotateCell(matrix [][]int, x, y int) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q49 implements a solution for https://leetcode.com/problems/group-anagrams/
|
||||
package q49
|
||||
|
||||
import "slices"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q5 implements a solution for https://leetcode.com/problems/longest-palindromic-substring/
|
||||
package q5
|
||||
|
||||
// Note: Although it can be done in O(N) with, e.g., Manacher's algorithm, the
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q50 implements a solution for https://leetcode.com/problems/powx-n/
|
||||
package q50
|
||||
|
||||
func myPow(x float64, n int) float64 {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q52 implements a solution for https://leetcode.com/problems/n-queens-ii/
|
||||
package q52
|
||||
|
||||
func findNSolutions(nQueen, row int, rows, cols, diag1, diag2 []bool) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q53 implements a solution for https://leetcode.com/problems/maximum-subarray/
|
||||
package q53
|
||||
|
||||
import "math"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q54 implements a solution for https://leetcode.com/problems/spiral-matrix/
|
||||
package q54
|
||||
|
||||
import "math"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q56 implements a solution for https://leetcode.com/problems/merge-intervals/
|
||||
package q56
|
||||
|
||||
import "slices"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q57 implements a solution for https://leetcode.com/problems/insert-interval/
|
||||
package q57
|
||||
|
||||
func insert(intervals [][]int, newInterval []int) [][]int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q58 implements a solution for https://leetcode.com/problems/length-of-last-word/
|
||||
package q58
|
||||
|
||||
func lengthOfLastWord(s string) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q6 implements a solution for https://leetcode.com/problems/zigzag-conversion/
|
||||
package q6
|
||||
|
||||
import "strings"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q61 implements a solution for https://leetcode.com/problems/rotate-list/
|
||||
package q61
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q62 implements a solution for https://leetcode.com/problems/unique-paths/
|
||||
package q62
|
||||
|
||||
func uniquePaths(m int, n int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q63 implements a solution for https://leetcode.com/problems/unique-paths-ii/
|
||||
package q63
|
||||
|
||||
func uniquePathsWithObstacles(obstacleGrid [][]int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q64 implements a solution for https://leetcode.com/problems/minimum-path-sum/
|
||||
package q64
|
||||
|
||||
func minPathSum(grid [][]int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q66 implements a solution for https://leetcode.com/problems/plus-one/
|
||||
package q66
|
||||
|
||||
func plusOne(digits []int) []int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q67 implements a solution for https://leetcode.com/problems/add-binary/
|
||||
package q67
|
||||
|
||||
func toDigit(byt byte) uint8 { return byt - '0' }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q68 implements a solution for https://leetcode.com/problems/text-justification/
|
||||
package q68
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q69 implements a solution for https://leetcode.com/problems/sqrtx/
|
||||
package q69
|
||||
|
||||
func mySqrt(x int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q70 implements a solution for https://leetcode.com/problems/climbing-stairs/
|
||||
package q70
|
||||
|
||||
func nWays(n, i int, cache []int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q71 implements a solution for https://leetcode.com/problems/simplify-path/
|
||||
package q71
|
||||
|
||||
import "strings"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q72 implements a solution for https://leetcode.com/problems/edit-distance/
|
||||
package q72
|
||||
|
||||
func make2d[T any](rows, cols int) [][]T {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q73 implements a solution for https://leetcode.com/problems/set-matrix-zeroes/
|
||||
package q73
|
||||
|
||||
func setZeroes(matrix [][]int) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q74 implements a solution for https://leetcode.com/problems/search-a-2d-matrix/
|
||||
package q74
|
||||
|
||||
func searchMatrix(matrix [][]int, target int) bool {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q77 implements a solution for https://leetcode.com/problems/combinations/
|
||||
package q77
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q79 implements a solution for https://leetcode.com/problems/word-search/
|
||||
package q79
|
||||
|
||||
func search(board [][]byte, word string, prefixLen, row, col int) bool {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q8 implements a solution for https://leetcode.com/problems/string-to-integer-atoi/
|
||||
package q8
|
||||
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q82 implements a solution for https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
|
||||
package q82
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q84 implements a solution for https://leetcode.com/problems/largest-rectangle-in-histogram/
|
||||
package q84
|
||||
|
||||
func largestRectangleArea(heights []int) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q85 implements a solution for https://leetcode.com/problems/maximal-rectangle/
|
||||
package q85
|
||||
|
||||
func maximalRectangle(matrix [][]byte) int {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q86 implements a solution for https://leetcode.com/problems/partition-list/
|
||||
package q86
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q9 implements a solution for https://leetcode.com/problems/palindrome-number/
|
||||
package q9
|
||||
|
||||
import "strconv"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q92 implements a solution for https://leetcode.com/problems/reverse-linked-list-ii/
|
||||
package q92
|
||||
|
||||
type ListNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q94 implements a solution for https://leetcode.com/problems/binary-tree-inorder-traversal/
|
||||
package q94
|
||||
|
||||
type TreeNode struct {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q97 implements a solution for https://leetcode.com/problems/interleaving-string/
|
||||
package q97
|
||||
|
||||
func isInterleave(s1 string, s2 string, s3 string) bool {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// Package q98 implements a solution for https://leetcode.com/problems/validate-binary-search-tree/
|
||||
package q98
|
||||
|
||||
type TreeNode struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue