diff --git a/go.mod b/go.mod index 1ed0983..c275cca 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module leetcode-go -go 1.26 +go 1.25.5 require ( github.com/emirpasic/gods/v2 v2.0.0-alpha @@ -10,6 +10,6 @@ require ( require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - golang.org/x/sys v0.41.0 // indirect - golang.org/x/text v0.34.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/text v0.33.0 // indirect ) diff --git a/go.sum b/go.sum index ab4f4a5..fe682d3 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/emirpasic/gods/v2 v2.0.0-alpha h1:dwFlh8pBg1VMOXWGipNMRt8v96dKAIvBehtCt6OtunU= github.com/emirpasic/gods/v2 v2.0.0-alpha/go.mod h1:W0y4M2dtBB9U5z3YlghmpuUhiaZT2h6yoeE+C1sCp6A= +github.com/k0kubun/pp/v3 v3.5.0 h1:iYNlYA5HJAJvkD4ibuf9c8y6SHM0QFhaBuCqm1zHp0w= +github.com/k0kubun/pp/v3 v3.5.0/go.mod h1:5lzno5ZZeEeTV/Ky6vs3g6d1U3WarDrH8k240vMtGro= github.com/k0kubun/pp/v3 v3.5.1 h1:fS8Xt0MWVVSiKwfXeIdE0WJlktdA87/gt0Hs0+j2R2s= github.com/k0kubun/pp/v3 v3.5.1/go.mod h1:s7qPOSp65uuilpprLJs2yDi9DNd7JGyWJPtPvDFpG9w= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= @@ -7,7 +9,11 @@ github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stg github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= -golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= -golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= diff --git a/solutions/14/q1461/solution.go b/solutions/14/q1461/solution.go deleted file mode 100644 index 8e45d8c..0000000 --- a/solutions/14/q1461/solution.go +++ /dev/null @@ -1,27 +0,0 @@ -package q1461 - -func hasAllCodes(s string, k int) bool { - if len(s) < (1<= k { - if i >= k { - c -= int(s[i-k]-'0') << k - } - - if !seen[c] { - seen[c] = true - nSeen++ - } - } - } - return nSeen == 1< 0; queue = queue[1:] { - z := queue[0] - par := (z + k) % 2 - - minFlipZ := max(k-(length-z), 0) - maxFlipZ := min(k, z) - minNewZ := z + k - 2*maxFlipZ - maxNewZ := z + k - 2*minFlipZ - - next, found := sets[par].Ceiling(minNewZ) - for ; found && next.Key <= maxNewZ; next, found = sets[par].Ceiling(minNewZ) { - nextZ := next.Key - sets[par].Remove(nextZ) - - nOps[nextZ] = nOps[z] + 1 - if nextZ%k == 0 { - return nOps[nextZ] + nextZ/k - } - queue = append(queue, nextZ) - } - } - return -1 -} - -var _ = minOperations diff --git a/solutions/7/q762/solution.go b/solutions/7/q762/solution.go deleted file mode 100644 index 7a3e164..0000000 --- a/solutions/7/q762/solution.go +++ /dev/null @@ -1,34 +0,0 @@ -package q762 - -var isPrime = [21]bool{} - -func init() { - for _, n := range []int{ - 2, 3, 5, 7, 11, 13, 17, 19, - } { - isPrime[n] = true - } -} - -func count1s(n int) int { - cnt := 0 - for n > 0 { - if n%2 == 1 { - cnt++ - } - n >>= 1 - } - return cnt -} - -func countPrimeSetBits(left, right int) int { - cnt := 0 - for n := left; n <= right; n++ { - if isPrime[count1s(n)] { - cnt++ - } - } - return cnt -} - -var _ = countPrimeSetBits diff --git a/solutions/7/q799/solution.go b/solutions/7/q799/solution.go deleted file mode 100644 index 94e909f..0000000 --- a/solutions/7/q799/solution.go +++ /dev/null @@ -1,23 +0,0 @@ -package q799 - -func champagneTower(poured, query_row, query_glass int) float64 { - buf := [100]float64{float64(poured)} - for r := range query_row + 1 { - var spill float64 = 0 - for c := range r + 1 { - if r == query_row && c == query_glass { - return max(buf[c], 1) - } - - if buf[c] > 1 { - buf[c] = (buf[c] - 1) / 2 - buf[c], spill = buf[c]+spill, buf[c] - } else { - buf[c], spill = spill, 0 - } - } - } - return 0 -} - -var _ = champagneTower diff --git a/solutions/8/q868/solution.go b/solutions/8/q868/solution.go deleted file mode 100644 index 23b3d67..0000000 --- a/solutions/8/q868/solution.go +++ /dev/null @@ -1,18 +0,0 @@ -package q868 - -func binaryGap(n int) int { - maxGap := -1 - gap := -99 - for n > 0 { - if n%2 == 0 { - gap++ - } else { - maxGap = max(maxGap, gap) - gap = 0 - } - n >>= 1 - } - return maxGap + 1 -} - -var _ = binaryGap