_022_05

package
v0.0.0-...-9cdbae4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlienOrder

func AlienOrder(words []string) string

AlienOrder 也可以使用dfs来找环 visit[],0没有遍历,1遍历中,2完成遍历,如果dfs一个点的时候发现一个为1的点,则判定成环,return false

func CutOffTree

func CutOffTree(forest [][]int) int

https://leetcode.cn/problems/cut-off-trees-for-golf-event/ 你被请来给一个要举办高尔夫比赛的树林砍树。树林由一个 m x n 的矩阵表示, 在这个矩阵中:. 0 表示障碍,无法触碰 1 表示地面,可以行走 比 1 大的数 表示有树的单元格,可以行走,数值表示树的高度 每一步,你都可以向上、下、左、右四个方向之一移动一个单位,如果你站的地方有一棵树,那么你可以决定是否要砍倒它。 你需要按照树的高度从低向高砍掉所有的树,每砍过一颗树,该单元格的值变为 1(即变为地面)。 你将从 (0, 0) 点开始工作,返回你砍完所有树需要走的最小步数。 如果你无法砍完所有的树,返回 -1 。 可以保证的是,没有两棵树的高度是相同的,并且你至少需要砍倒一棵树。

func FindRightInterval

func FindRightInterval(intervals [][]int) []int

查找换成2分查找就不超时了, 感觉可以用回溯做,待解决

func RemoveOuterParentheses

func RemoveOuterParentheses(s string) string

https://leetcode.cn/problems/remove-outermost-parentheses/ 有效括号字符串为空 ""、"(" + A + ")" 或 A + B ,其中 A 和 B 都是有效的括号字符串,+ 代表字符串的连接。

例如,"","()","(())()" 和 "(()(()))" 都是有效的括号字符串。 如果有效字符串 s 非空,且不存在将其拆分为 s = A + B 的方法,我们称其为原语(primitive),其中 A 和 B 都是非空有效括号字符串。

给出一个非空有效字符串 s,考虑将其进行原语化分解,使得:s = P_1 + P_2 + ... + P_k,其中 P_i 是有效括号字符串原语。

对 s 进行原语化分解,删除分解中每个原语字符串的最外层括号,返回 s 。

func SumRootToLeaf

func SumRootToLeaf(root *binaryTree.Node) int

https://leetcode.cn/problems/sum-of-root-to-leaf-binary-numbers/ 给出一棵二叉树,其上每个结点的值都是 0 或 1 。每一条从根到叶的路径都代表一个从最高有效位开始的二进制数。

例如,如果路径为 0 -> 1 -> 1 -> 0 -> 1,那么它表示二进制数 01101,也就是 13 。 对树上的每一片叶子,我们都要找出从根到该叶子的路径所表示的数字。

返回这些数字之和。题目数据保证答案是一个 32 位 整数。

func TLEback

func TLEback(n int, desTotal int, curTotal int, vis []bool) bool

func TLEcanIWin

func TLEcanIWin(maxChoosableInteger int, desiredTotal int) bool

TLE //41/57 //case: //20 //210

func ValidIPAddress

func ValidIPAddress(queryIP string) string

Types

type Codec

type Codec struct {
}

func Constructor

func Constructor() (_ Codec)

func (*Codec) Deserialize

func (_ *Codec) Deserialize(data string) *binaryTree.Node

Deserializes your encoded data to tree.

func (*Codec) Deserialize2

func (_ *Codec) Deserialize2(data string) *binaryTree.Node

func (*Codec) Serialize

func (_ *Codec) Serialize(root *binaryTree.Node) string

Serializes a tree to a single string.

func (*Codec) Serialize2

func (c *Codec) Serialize2(root *binaryTree.Node) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL