LeetCode 824 Goat Latin 解题报告

摘要: 题目要求 A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to conver 阅读全文
posted @ 2019-03-14 09:33 锋上磬音 阅读(87) 评论(0) 推荐(0) 编辑

LeetCode 888 Fair Candy Swap 解题报告

摘要: 题目要求 Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar 阅读全文
posted @ 2019-03-13 09:49 锋上磬音 阅读(103) 评论(0) 推荐(0) 编辑

LeetCode 953 Verifying an Alien Dictionary 解题报告

摘要: 题目要求 In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some 阅读全文
posted @ 2019-03-12 10:01 锋上磬音 阅读(195) 评论(0) 推荐(0) 编辑

LeetCode 976 Largest Perimeter Triangle 解题报告

摘要: 题目要求 Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths. If it is imp 阅读全文
posted @ 2019-03-11 09:44 锋上磬音 阅读(136) 评论(0) 推荐(0) 编辑

LeetCode 226 Invert Binary Tree 解题报告

摘要: 题目要求 Invert a binary tree. 题目分析及思路 给定一棵二叉树,要求每一层的结点逆序。可以使用递归的思想将左右子树互换。 python代码 # Definition for a binary tree node. # class TreeNode: # def __init__ 阅读全文
posted @ 2019-03-10 09:44 锋上磬音 阅读(148) 评论(0) 推荐(0) 编辑

LeetCode 693 Binary Number with Alternating Bits 解题报告

摘要: 题目要求 Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. 题目分析及思路 给定一个正整数, 阅读全文
posted @ 2019-03-09 09:36 锋上磬音 阅读(84) 评论(0) 推荐(0) 编辑

LeetCode 762 Prime Number of Set Bits in Binary Representation 解题报告

摘要: 题目要求 Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary represent 阅读全文
posted @ 2019-03-08 10:26 锋上磬音 阅读(162) 评论(0) 推荐(0) 编辑

LeetCode 637 Average of Levels in Binary Tree 解题报告

摘要: 题目要求 Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. 题目分析及思路 给定一棵非空二叉树,要求以列表的形式返回每一层结点值的平均 阅读全文
posted @ 2019-03-07 09:31 锋上磬音 阅读(175) 评论(0) 推荐(0) 编辑

LeetCode 429 N-ary Tree Level Order Traversal 解题报告

摘要: 题目要求 Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). 题目分析及思路 给定一棵N叉树,要求返回它的层次遍历结 阅读全文
posted @ 2019-03-06 10:54 锋上磬音 阅读(85) 评论(0) 推荐(0) 编辑

LeetCode 566 Reshape the Matrix 解题报告

摘要: 题目要求 In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original 阅读全文
posted @ 2019-03-05 09:28 锋上磬音 阅读(176) 评论(0) 推荐(0) 编辑