aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--124/main.go1
-rwxr-xr-x2610/2125/main.py26
-rw-r--r--872/main.go1
-rw-r--r--876/main.cpp2
-rw-r--r--886/main.go2
-rwxr-xr-x[-rw-r--r--]931/main.go4
-rw-r--r--938/872/go.mod3
-rw-r--r--938/872/main.go74
8 files changed, 4 insertions, 109 deletions
diff --git a/124/main.go b/124/main.go
index fa953f1..73a515a 100644
--- a/124/main.go
+++ b/124/main.go
@@ -26,6 +26,7 @@ func walk(node *TreeNode, sum *int) int {
left := max(0, walk(node.Left, sum))
right := max(0, walk(node.Right, sum))
+ fmt.Println(left, right, sum)
*sum = max(*sum, left+right+node.Val)
return max(left, right) + node.Val
diff --git a/2610/2125/main.py b/2610/2125/main.py
deleted file mode 100755
index da45c29..0000000
--- a/2610/2125/main.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-
-import typing
-
-
-class Solution:
- def numberOfBeams(self, bank: typing.List[str]) -> int:
- row_count = 0
- result = 0
- for row in bank:
- count = row.count("1")
- if count != 0:
- result += row_count * count
- row_count = row.count("1")
-
- return result
-
-
-def main():
- solution = Solution()
- print(solution.numberOfBeams(["011001", "000000", "010100", "00100"]))
- print(solution.numberOfBeams(["000", "111", "000"]))
-
-
-if __name__ == "__main__":
- main()
diff --git a/872/main.go b/872/main.go
index 24ef0ab..d71a335 100644
--- a/872/main.go
+++ b/872/main.go
@@ -70,5 +70,4 @@ func main() {
node4.Right = &node5
fmt.Println(leafSimilar(&node1, &node4))
-
}
diff --git a/876/main.cpp b/876/main.cpp
index 20d49ad..8bee31f 100644
--- a/876/main.cpp
+++ b/876/main.cpp
@@ -22,7 +22,7 @@ public:
heads.push_back(head);
int size = heads.size();
- std::cout << "size:" << size << "\n";
+ /* std::cout << "size:" << size << "\n"; */
return heads[int(size / 2)];
}
};
diff --git a/886/main.go b/886/main.go
index d06b3b8..8979d71 100644
--- a/886/main.go
+++ b/886/main.go
@@ -60,7 +60,7 @@ func possibleBipartition(n int, dislikes [][]int) bool {
return color[u] == c
}
- //fmt.Printf("node: %d will mark color: %d\n", u, c)
+ fmt.Printf("node: %d will mark color: %d\n", u, c)
color[u] = c
for _, v := range edges[u] {
if !dfs(v, -c) {
diff --git a/931/main.go b/931/main.go
index b05fb8e..f6df355 100644..100755
--- a/931/main.go
+++ b/931/main.go
@@ -51,15 +51,13 @@ func dumpMatrix(matrix [][]int) {
func minFallingPathSum(matrix [][]int) int {
for i := 1; i < len(matrix[0]); i++ {
for j := 0; j < len(matrix[0]); j++ {
- // matrix[i][j] += min(matrix[i-1][j], min(matrix[i-1][max(0, j-1)], matrix[i-1][min(len(matrix[0])-1, j+1)]))
matrix[i][j] += min3(matrix[i-1][j], matrix[i-1][max(0, j-1)], matrix[i-1][min(len(matrix[0])-1, j+1)])
}
}
- // dumpMatrix(matrix)
+ dumpMatrix(matrix)
return getRowMin(matrix[len(matrix[0])-1])
-
}
func main() {
diff --git a/938/872/go.mod b/938/872/go.mod
deleted file mode 100644
index 10fbec9..0000000
--- a/938/872/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module 872
-
-go 1.18
diff --git a/938/872/main.go b/938/872/main.go
deleted file mode 100644
index 24ef0ab..0000000
--- a/938/872/main.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package main
-
-import "fmt"
-
-type TreeNode struct {
- Val int
- Left *TreeNode
- Right *TreeNode
-}
-
-func preorderVisit(node *TreeNode, leafSequence *[]int) {
- if node == nil {
- return
- }
- if node.Left == nil && node.Right == nil {
- *leafSequence = append(*leafSequence, node.Val)
- return
- }
-
- preorderVisit(node.Left, leafSequence)
- preorderVisit(node.Right, leafSequence)
-}
-
-func leafSimilar(root1, root2 *TreeNode) bool {
- var leafSequence1 []int
- var leafSequence2 []int
-
- preorderVisit(root1, &leafSequence1)
- preorderVisit(root2, &leafSequence2)
-
- // for i := 0; i < len(leafSequence1); i++ {
- // fmt.Println((leafSequence1)[i])
- // }
- // for i := 0; i < len(leafSequence2); i++ {
- // fmt.Println((leafSequence2)[i])
- // }
-
- if len(leafSequence1) != len(leafSequence2) {
- return false
- }
-
- for i := 0; i < len(leafSequence1); i++ {
- if (leafSequence1)[i] != (leafSequence2)[i] {
- return false
- }
- }
-
- return true
-}
-
-func main() {
- var node1 TreeNode
- var node2 TreeNode
- var node3 TreeNode
- node1.Val = 1
- node2.Val = 2
- node3.Val = 3
-
- node1.Left = &node2
- node1.Right = &node3
-
- var node4 TreeNode
- var node5 TreeNode
- var node6 TreeNode
- node4.Val = 1
- node5.Val = 2
- node6.Val = 3
-
- node4.Left = &node6
- node4.Right = &node5
-
- fmt.Println(leafSimilar(&node1, &node4))
-
-}