LeetCode
文章平均质量分 75
迅丶
我机智的一匹
展开
-
【LeetCode】226. Invert Binary Tree
226. Invert Binary TreeProblemExampleSolutionProblem翻转二叉树Example输入: 4 / \ 2 7 / \ / \1 3 6 9输出: 4 / \ 7 2 / \ / \9 6 3 1Solution递归的交换左右子树/**...原创 2018-12-25 23:02:12 · 94 阅读 · 0 评论 -
【LeetCode】693. Binary Number with Alternating Bits
693. Binary Number with Alternating BitsProblemExampleSolutionProblem给一个正整数,判断他的二进制形式 是否是0,1交替的Example5(101) true7(111) false10(1010) true11(1011)falseSolution如果是最低位为0,如1010,先右移一位,方便计算...原创 2018-12-25 21:34:11 · 94 阅读 · 0 评论 -
【LeetCode】762. Prime Number of Set Bits in Binary Representation
Prime Number of Set Bits in Binary RepresentationProblemExampleSolution一堆题放一块太挤了,还是分开放=.=,也能写得详细一点Problem求[L,R]这个闭区间内的数字 二进制表示形式 1的个数 为素数 的数量ExampleL = 6, R = 106(0101),1的个数为2,2是素数 +17(1001)...原创 2018-12-24 21:37:37 · 134 阅读 · 0 评论 -
【LeetCode】Day5
文章目录412. Fizz Buzz953. Verifying an Alien Dictionary566. Reshape the Matrix104. Maximum Depth of Binary Tree136. Single Number429. N-ary Tree Level Order Traversal637. Average of Levels in Binary Tree...原创 2018-12-23 18:43:02 · 138 阅读 · 0 评论 -
【LeetCode】Day 4
文章目录500. Keyboard Row872. Leaf-Similar Trees893. Groups of Special-Equivalent Strings766. Toeplitz Matrix884. Uncommon Words from Two Sentences897. Increasing Order Search Tree463. Island Perimeter682...原创 2018-12-23 14:30:11 · 230 阅读 · 0 评论 -
【LeetCode】896. Monotonic Array
896. Monotonic ArrayProblemExampleSolutionProblem判断一个数组是否为单调不减或单调不增数组。i <= j ,A[i] <= A[j]或i >= j , A[i] >= A[j]ExampleInput: [1,2,2,3]Output: trueInput: [6,5,4,4]Output: tru...原创 2018-12-27 00:15:38 · 115 阅读 · 0 评论 -
【LeetCode】892. Surface Area of 3D Shapes
892. Surface Area of 3D ShapesProblemExampleSolutionProblem求3D图形的表面积。二维数组v = grid[i][j],v表示图形的高,(i,j)表示所在的格子位置Example输入:[[2]]输出:10解释: 3D图形有4个侧面,面积都一样,两个上下面。S = 4 * h(高)+ 2 * 1输入:[[1,2],[3,4...原创 2018-12-26 23:19:57 · 140 阅读 · 0 评论 -
【LeetCode】292. Nim Game
292. Nim GameProblemExampleSolutionProblem你和朋友在玩一个游戏,桌上有一堆石头,你俩每次轮流拿走1到3个石头,拿走最后剩余石头的就是赢家。你先开始拿。你俩都很聪明,会选最佳策略。写一个方法,初始有多少个石头,你会赢。Example输入:4输出:false解释:不管你拿1,2,3个石头,剩下3,2,1个石头都会被朋友一次性拿光,所以输。...原创 2018-12-26 21:59:53 · 286 阅读 · 0 评论 -
【LeetCode】521. Longest Uncommon Subsequence I
521. Longest Uncommon Subsequence IProblemExampleSolutionProblem最长 不公共 子串Example输入:“aba”, “cdc”输出:3解释:左子串的最长子串为自己,右边也是,他们不相等,所以为3输入:“asdf”,“asd”输出:3解释:左边最长字串为自己长度为4,右边最长为自己,长度为3,最长的不公共字串就为...原创 2018-12-26 21:43:16 · 94 阅读 · 0 评论 -
【LeetCode】Day 3
文章目录933. Number of Recent Calls933. Number of Recent Calls原创 2018-11-29 18:45:57 · 157 阅读 · 0 评论 -
【LeetCode】Day 1
文章目录771. Jewels and Stones929. Unique Email Addresses709. To Lower Case944. Delete Columns to Make Sorted804. Unique Morse Code Words905. Sort Array By Parity771. Jewels and Stones给一字符串 J (大小写敏感)和一...原创 2018-11-23 22:53:00 · 175 阅读 · 0 评论 -
【LeetCode】 Day 2
文章目录657. Robot Return to Origin461. Hamming Distance832. Flipping an Image617. Merge Two Binary Trees728. Self Dividing Numbers561. Array Partition I852. Peak Index in a Mountain Array942. DI String M...原创 2018-11-24 19:11:53 · 126 阅读 · 0 评论 -
【LeetCode】917. Reverse Only Letters
917. Reverse Only LettersProblemExampleSolutionProblem给一个字符串,只反转其中的字母ExampleInput: “ab-cd”Output: “dc-ba”Input: “a-bC-dEf-ghIj”Output: “j-Ih-gfE-dCba”Input: “Test1ng-Leet=code-Q!”Outpu...原创 2018-12-25 23:24:04 · 131 阅读 · 0 评论