03 2019 档案

LeetCode 788 Rotated Digits 解题报告
摘要:题目要求 X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be r 阅读全文

posted @ 2019-03-31 09:47 锋上磬音 阅读(134) 评论(0) 推荐(0)

LeetCode 206 Reverse Linked List 解题报告
摘要:题目要求 Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL 题目分析及思路 给定一个单链表,要求得到它的逆序。可以使用列表对链表结点进行保存,之后新建一个列表对链 阅读全文

posted @ 2019-03-30 09:25 锋上磬音 阅读(139) 评论(0) 推荐(0)

LeetCode 690 Employee Importance 解题报告
摘要:题目要求 You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates 阅读全文

posted @ 2019-03-29 09:41 锋上磬音 阅读(94) 评论(0) 推荐(0)

LeetCode 349 Intersection of Two Arrays 解题报告
摘要:题目要求 Given two arrays, write a function to compute their intersection. 题目分析及思路 给定两个数组,要求得到它们之中共同拥有的元素列表(列表中元素是唯一的)。可以将所给数组转成集合,利用集合的交集的概念,最后将结果转成列表即可。 阅读全文

posted @ 2019-03-28 09:28 锋上磬音 阅读(79) 评论(0) 推荐(0)

LeetCode 258 Add Digits 解题报告
摘要:题目要求 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. 题目分析及思路 给定一个非负整数,要求将它的各位数相加得到一个新数并对该新数重复进行这样 阅读全文

posted @ 2019-03-27 09:31 锋上磬音 阅读(96) 评论(0) 推荐(0)

LeetCode 748 Shortest Completing Word 解题报告
摘要:题目要求 Find the minimum length word from a given dictionary words, which has all the letters from the string licensePlate. Such a word is said to comple 阅读全文

posted @ 2019-03-26 09:57 锋上磬音 阅读(172) 评论(0) 推荐(0)

LeetCode 283 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. 题目分析及思路 给定一 阅读全文

posted @ 2019-03-25 10:00 锋上磬音 阅读(93) 评论(0) 推荐(0)

LeetCode 485 Max Consecutive Ones 解题报告
摘要:题目要求 Given a binary array, find the maximum number of consecutive 1s in this array. 题目分析及思路 给定一个01数组,要求找到这个数组中连续1的最大长度。可以考虑0的位置,结合数组切片,循环进行。要记得把最后数组的长 阅读全文

posted @ 2019-03-24 09:58 锋上磬音 阅读(111) 评论(0) 推荐(0)

LeetCode 896 Monotonic Array 解题报告
摘要:题目要求 An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[ 阅读全文

posted @ 2019-03-23 14:35 锋上磬音 阅读(88) 评论(0) 推荐(0)

LeetCode 706 Design HashMap 解题报告
摘要:题目要求 Design a HashMap without using any built-in hash table libraries. To be specific, your design should include these functions: put(key, value) : I 阅读全文

posted @ 2019-03-22 09:55 锋上磬音 阅读(131) 评论(0) 推荐(0)

LeetCode 427 Construct Quad Tree 解题报告
摘要:题目要求 We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only be true or false. The root node represents the whole gri 阅读全文

posted @ 2019-03-21 10:32 锋上磬音 阅读(134) 评论(0) 推荐(0)

LeetCode 812 Largest Triangle Area 解题报告
摘要:题目要求 You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points. 题目分析及思路 给定一个平面上的一组点,要求 阅读全文

posted @ 2019-03-20 09:32 锋上磬音 阅读(191) 评论(0) 推荐(0)

LeetCode 292 Nim Game 解题报告
摘要:题目要求 You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 阅读全文

posted @ 2019-03-19 09:53 锋上磬音 阅读(132) 评论(0) 推荐(0)

LeetCode 1012 Complement of Base 10 Integer 解题报告
摘要:题目要求 Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on 阅读全文

posted @ 2019-03-18 09:18 锋上磬音 阅读(252) 评论(0) 推荐(0)

LeetCode 784 Letter Case Permutation 解题报告
摘要:题目要求 Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible 阅读全文

posted @ 2019-03-17 10:27 锋上磬音 阅读(151) 评论(0) 推荐(0)

LeetCode 892 Surface Area of 3D Shapes 解题报告
摘要:题目要求 On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Return 阅读全文

posted @ 2019-03-16 09:46 锋上磬音 阅读(92) 评论(0) 推荐(0)

LeetCode 917 Reverse Only Letters 解题报告
摘要:题目要求 Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their p 阅读全文

posted @ 2019-03-15 09:20 锋上磬音 阅读(186) 评论(0) 推荐(0)

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 锋上磬音 阅读(97) 评论(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 锋上磬音 阅读(122) 评论(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 锋上磬音 阅读(205) 评论(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 锋上磬音 阅读(140) 评论(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 锋上磬音 阅读(157) 评论(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 锋上磬音 阅读(96) 评论(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 锋上磬音 阅读(179) 评论(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 锋上磬音 阅读(179) 评论(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 锋上磬音 阅读(94) 评论(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 锋上磬音 阅读(181) 评论(0) 推荐(0)

LeetCode 496 Next Greater Element I 解题报告
摘要:题目要求 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for n 阅读全文

posted @ 2019-03-04 10:06 锋上磬音 阅读(139) 评论(0) 推荐(0)

LeetCode 412 Fizz Buzz 解题报告
摘要:题目要求 Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the 阅读全文

posted @ 2019-03-03 09:17 锋上磬音 阅读(263) 评论(0) 推荐(0)

LeetCode 937 Reorder Log Files 解题报告
摘要:题目要求 You have an array of logs. Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifier. 阅读全文

posted @ 2019-03-02 10:08 锋上磬音 阅读(203) 评论(0) 推荐(0)

LeetCode 136 Single Number 解题报告
摘要:题目要求 Given a non-empty array of integers, every element appears twice except for one. Find that single one. 题目分析及思路 给定一个非空整数数组,除了一个元素只出现一次外,其余元素均出现两次。 阅读全文

posted @ 2019-03-01 10:03 锋上磬音 阅读(80) 评论(0) 推荐(0)