摘要: 274. H 指数 - 力扣(LeetCode) 思路 func hIndex(citations []int) int { h := 0 sort.Ints(citations) for i := len(citations) - 1; i >= 0 && citations[i] > h; i- 阅读全文
posted @ 2022-05-10 04:51 SoutherLea 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 498. 对角线遍历 - 力扣(LeetCode) 思路 找规律 1. 设x,y为数组下标,x+y为偶数时,向右上遍历。x+y为奇数时,向左下遍历。 2. 在向左下遍历时 先考虑边界1 当前在最后一行,则向右移动一格 y+1;再考虑边界 2 当前在第一列,向下移动一格 x+1; 其他情况 x+1,y 阅读全文
posted @ 2022-05-10 04:30 SoutherLea 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 79. 单词搜索 - 力扣(LeetCode) 思路 还是回溯 func exist(board [][]byte, word string) bool { if len(board) < 1 || len(board[0]) > 6 || len(word) > 15 || len(word) < 阅读全文
posted @ 2022-05-10 02:34 SoutherLea 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 494. 目标和 - 力扣(LeetCode) 思路 依然是回溯法 func findTargetSumWays(nums []int, target int) int { res := 0 if len(nums) == 0 { return 0 } var backTracking func(n 阅读全文
posted @ 2022-05-10 00:29 SoutherLea 阅读(13) 评论(0) 推荐(0) 编辑