![](https://img-blog.csdnimg.cn/20190918140158853.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
LeetCode
文章平均质量分 61
leetcode刷题
叨陪鲤
哈
展开
-
LeetCode刷题模板(1):《我要打10个》之二分法
二分法 什么是二分查找 二分查找也称折半查找(Binary Search),它是一种效率较高的查找方法,前提是数据结构必须先排好序,可以在数据规模的对数时间复杂度内完成查找。但是,二分查找要求线性表具有有随机访问的特点(例如数组),也要求线性表能够根据中间元素的特点推测它两侧元素的性质,以达到缩减问题规模的效果 二分查找是计算机科学中最基本、最有用的算法之一。 它描述了在有序集合中搜索特定值的过程。二分查找中的经常使用的术语:目标 Target:你要查找的值 索引...原创 2021-03-13 23:18:08 · 4191 阅读 · 0 评论 -
二分法模板
package mainimport "fmt"// 《通过刷leetcode学习Go语言》之(1):二分法模板func solution(nums []int, target int) int { if nums == nil { return -1 } left, right := 0, len(nums)-1 for left <= right { /*注意循环条件为: left <= right*/ mid := left + (right-left)&.原创 2021-03-08 00:17:34 · 4333 阅读 · 0 评论 -
《通过刷leetcode学习Go语言》之(1):序言
Author : Email : vip_13031075266@163.com Date : 2021.03.07 Version : 北京 Copyright: 未经同意不得转载!!! Reference:https://leetcode-cn.com/problemset/all/ 写给自己的序:从事LinuxC开发有3年了,这期间基本都是使用C语言写bug。日常工作除了薪...原创 2021-03-07 23:27:23 · 4454 阅读 · 0 评论 -
404. Sum of Left Leaves
404. Sum of Left Leaves1. 题目Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.2. 题解: 解题思路: 递归函数中借助一个变量原创 2020-09-19 09:07:09 · 4251 阅读 · 0 评论 -
102. Binary Tree Level Order Traversal
102. Binary Tree Level Order Traversal1. 题目Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15原创 2020-09-18 23:46:31 · 4425 阅读 · 0 评论 -
101. Symmetric Tree
101. Symmetric Tree1. 题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For Example:This binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following [1,2,2,null,3,nu原创 2020-09-18 01:03:42 · 4305 阅读 · 0 评论 -
145. Binary Tree Postorder Traversal
145. Binary Tree Postorder Traversal1. 题目Given the root of a binary tree, return the postorder traversal of its nodes’ values.Follow up: Recursive solution is trivial, could you do it iteratively?Example1:Input: root = [1,null,2,3]Output: [3,2,1]原创 2020-09-17 08:55:07 · 4288 阅读 · 0 评论 -
226. Invert Binary Tree
226. Invert Binary Tree1. 问题Invert a binary tree.Example:input: 4 / \ 2 7 / \ / \1 3 6 9output: 4 / \ 7 2 / \ / \9 6 3 1轶事:牛逼的工程师都这样吗???Google: 90% of our engineers use the software you wrote (Home原创 2020-09-16 22:16:29 · 4280 阅读 · 0 评论 -
94. Binary Tree Inorder Traversal
94. Binary Tree Inorder Traversal1. 问题Given a binary tree, return the inorder traversal of its nodes’ values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Follow up: Recursive solution is trivial, could you do it iterativ原创 2020-09-15 22:54:18 · 4193 阅读 · 0 评论