
LeetCode
文章平均质量分 75
善哉丶丶
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeetCode]Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example:Given binary tree [3,9,20,null...原创 2018-03-07 10:34:10 · 158 阅读 · 0 评论 -
[LeetCode]Invert a binary tree.
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1 思路:立马想到递归,出口立马想到是root为NULL。问题就在与循环体上,既然是反转左右树,那么以任意节点为例,只需要将其左树的值转为右树的值,右树的值转为左树...原创 2018-03-07 10:53:52 · 157 阅读 · 0 评论 -
[LeetCode]Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your fun...原创 2018-03-07 11:30:22 · 152 阅读 · 0 评论 -
[LeetCode]Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could yo...原创 2018-03-08 10:25:41 · 172 阅读 · 0 评论 -
[LeetCode]Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x, y < 231Exam...原创 2018-03-05 12:53:10 · 183 阅读 · 0 评论 -
[LeetCode]Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree....原创 2018-03-06 10:54:00 · 240 阅读 · 0 评论 -
[LeetCode] Single Number
Given an array of integers, every element appears twice except for one. Find that single one.思路:1)可以使用python字典,遍历一遍数组,将出现次数设为value,将数值设为key。最后找出出现次数为1的键值。2)由于所有的数只有一个出现一次可以使用set()选出所有不重复的数字乘二再减原数组集合结果...原创 2018-03-06 12:38:35 · 167 阅读 · 0 评论