Medium
你看见我的代码了么
愿世界没有bug
展开
-
[leetcode]338. Counting Bits
[leetcode]338. Counting BitsAnalysis 周五ummmmmm—— [啊啊啊啊 paper结果要出来了,心塞]Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in ...原创 2018-08-03 20:31:18 · 81 阅读 · 0 评论 -
[leetcode]791. Custom Sort String
[leetcode]791. Custom Sort StringAnalysis 周五ummmmmm—— [啊啊啊啊 paper结果要出来了,心塞]S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some ...原创 2018-08-03 21:00:46 · 98 阅读 · 0 评论 -
[leetcode]442. Find All Duplicates in an Array
[leetcode]442. Find All Duplicates in an ArrayAnalysis 周五ummmmmm—— [啊啊啊啊 paper结果要出来了,心塞]Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and othe...原创 2018-08-04 09:58:25 · 82 阅读 · 0 评论 -
[leetcode]841. Keys and Rooms
[leetcode]841. Keys and RoomsAnalysis 中午吃啥?—— [啊啊啊啊 paper结果真的要出来了,心塞]There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have...原创 2018-08-04 10:25:21 · 151 阅读 · 0 评论 -
[leetcode]406. Queue Reconstruction by Height
[leetcode]406. Queue Reconstruction by HeightAnalysis 中午吃啥?—— [啊啊啊啊 paper结果真的要出来了,心塞]Suppose you have a random list of people standing in a queue. Each person is described by a pair of in...原创 2018-08-04 11:08:15 · 71 阅读 · 0 评论 -
[leetcode]807. Max Increase to Keep City Skyline
[leetcode]807. Max Increase to Keep City SkylineAnalysis 周二快乐~—— [ummm~]In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allow...原创 2018-07-31 20:35:01 · 113 阅读 · 0 评论 -
[leetcode]654. Maximum Binary Tree
[leetcode]654. Maximum Binary TreeAnalysis 周二快乐~—— [ummm~]Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: The root is the maximum nu...原创 2018-07-31 21:02:48 · 132 阅读 · 0 评论 -
[leetcode]861. Score After Flipping Matrix
[leetcode]861. Score After Flipping MatrixAnalysis 周三不快乐~—— [ummm~]We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row or column, and toggli...原创 2018-08-01 15:56:16 · 110 阅读 · 0 评论 -
[leetcode]513. Find Bottom Left Tree Value
[leetcode]513. Find Bottom Left Tree ValueAnalysis 啊啊啊啊啊啊—— [啊啊啊啊 paper结果怎么还不出来,心塞]Given a binary tree, find the leftmost value in the last row of the tree. 层序遍历,每一层取第一个节点值,然后更新~Implem...原创 2018-08-06 19:47:17 · 86 阅读 · 0 评论 -
[leetcode]515. Find Largest Value in Each Tree Row
[leetcode]515. Find Largest Value in Each Tree RowAnalysis 啊啊啊啊啊啊—— [生死有命富贵在天]You need to find the largest value in each row of a binary tree. 层序遍历,然后找到每一层的最大值就行了~Implement方法一(层序遍历)...原创 2018-08-06 20:06:14 · 74 阅读 · 0 评论 -
[leetcode]540. Single Element in a Sorted Array
[leetcode]540. Single Element in a Sorted ArrayAnalysis 啊啊啊啊啊啊—— [生死有命富贵在天]Given a sorted array consisting of only integers where every element appears twice except for one element which a...原创 2018-08-06 20:45:33 · 83 阅读 · 0 评论 -
[leetcode]553. Optimal Division
[leetcode]553. Optimal DivisionAnalysis 啊啊啊啊啊啊—— [生死有命富贵在天]Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4. ...原创 2018-08-06 21:08:39 · 121 阅读 · 0 评论 -
[leetcode]814. Binary Tree Pruning
[leetcode]814. Binary Tree PruningAnalysis 周四不知道快不快乐—— [有点想回家过暑假的冲动!]We are given the head node root of a binary tree, where additionally every node’s value is either a 0 or a 1. Return t...原创 2018-08-02 17:29:49 · 105 阅读 · 0 评论 -
[leetcode]797. All Paths From Source to Target
[leetcode]797. All Paths From Source to TargetAnalysis 周四不知道快不快乐—— [有点想回家过暑假的冲动!]Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return th...原创 2018-08-02 17:53:21 · 174 阅读 · 0 评论 -
[leetcode]763. Partition Labels
[leetcode]763. Partition LabelsAnalysis 周四不知道快不快乐—— [有点想回家过暑假的冲动!]A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each let...原创 2018-08-02 19:47:36 · 144 阅读 · 0 评论 -
[leetcode]537. Complex Number Multiplication
[leetcode]537. Complex Number MultiplicationAnalysis 周四不知道快不快乐—— [有点想回家过暑假的冲动!]Given two strings representing two complex numbers.You need to return a string representing their multiplic...原创 2018-08-02 20:05:10 · 64 阅读 · 0 评论 -
[leetcode]419. Battleships in a Board
[leetcode]419. Battleships in a BoardAnalysis 周四不知道快不快乐—— [有点想回家过暑假的冲动!]Given an 2D board, count how many battleships are in it. The battleships are represented with ‘X’s, empty slots are ...原创 2018-08-02 21:01:44 · 83 阅读 · 0 评论 -
[leetcode]526. Beautiful Arrangement
[leetcode]526. Beautiful ArrangementAnalysis 虚惊一场~—— [好好养生!!]Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the su...原创 2018-09-04 20:06:04 · 123 阅读 · 0 评论 -
[leetcode]451. Sort Characters By Frequency
[leetcode]451. Sort Characters By FrequencyAnalysis 虚惊一场~—— [好好养生!!]Given a string, sort it in decreasing order based on the frequency of characters. 先吧字符以及其出现次数存入hash表中,然后再把hash表中的字符和出现次...原创 2018-09-04 20:57:16 · 140 阅读 · 0 评论 -
[leetcode]817. Linked List Components
[leetcode]817. Linked List ComponentsAnalysis ummmmm~—— [ummmm]We are given head, the head node of a linked list containing unique integer values. We are also given the list G, a subset o...原创 2018-09-07 19:17:25 · 96 阅读 · 0 评论 -
[leetcode]667. Beautiful Arrangement II
[leetcode]667. Beautiful Arrangement IIAnalysis ummmmm~—— [ummmm]Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n a...原创 2018-09-07 19:54:46 · 100 阅读 · 0 评论 -
[leetcode]347. Top K Frequent Elements
[leetcode]347. Top K Frequent ElementsAnalysis ummmmm~—— [ummmm]Given a non-empty array of integers, return the k most frequent elements. 先用hash table把每个元素及其出现次数统计出来,然后再根据出现次数排序,输出前k个元素~...原创 2018-09-07 20:29:49 · 94 阅读 · 0 评论 -
[leetcode]677. Map Sum Pairs
[leetcode]677. Map Sum PairsAnalysis ummmmm~—— [ummmm]Implement a MapSum class with insert, and sum methods. For the method insert, you’ll be given a pair of (string, integer). The string...原创 2018-09-07 21:11:19 · 135 阅读 · 0 评论 -
[leetcode]789. Escape The Ghosts
[leetcode]789. Escape The GhostsAnalysis 想把拖鞋赛道实验室某男生嘴里!!!—— [生气气]You are playing a simplified Pacman game. You start at the point (0, 0), and your destination is (target[0], target[1]). T...原创 2018-09-05 10:59:09 · 118 阅读 · 0 评论 -
[leetcode]94. Binary Tree Inorder Traversal
[leetcode]94. Binary Tree Inorder TraversalAnalysis 想把拖鞋赛道实验室某男生嘴里!!!—— [生气气]Given a binary tree, return the inorder traversal of its nodes’ values. 中序遍历保存节点值。。。Implement/** * Defi...原创 2018-09-05 14:11:05 · 75 阅读 · 0 评论 -
[leetcode]748. Shortest Completing Word
[leetcode]748. Shortest Completing WordAnalysis 想把拖鞋塞到某男生嘴里!!!—— [生气气]Find the minimum length word from a given dictionary words, which has all the letters from the string licensePlate. Su...原创 2018-09-05 14:21:24 · 196 阅读 · 0 评论 -
[leetcode]676. Implement Magic Dictionary
[leetcode]676. Implement Magic DictionaryAnalysis 年纪大了换季就会感冒—— [ummmm~]Implement a magic directory with buildDict, and search methods. For the method buildDict, you’ll be given a list of ...原创 2018-09-11 19:27:29 · 115 阅读 · 0 评论 -
[leetcode]641. Design Circular Deque
[leetcode]641. Design Circular DequeAnalysis 年纪大了换季就会感冒—— [ummmm~]Design your implementation of the circular double-ended queue (deque). Your implementation should support following opera...原创 2018-09-11 19:55:47 · 259 阅读 · 0 评论 -
[leetcode]856. Score of Parentheses
[leetcode]856. Score of ParenthesesAnalysis 心疼奶茶妹妹~—— [马云爸爸恐成最大赢家 哈哈哈]Given a balanced parentheses string S, compute the score of the string based on the following rule: () has score 1 A...原创 2018-09-03 14:38:52 · 269 阅读 · 0 评论 -
[leetcode]260. Single Number III
[leetcode]260. Single Number IIIAnalysis 心态奶茶妹妹~—— [马云爸爸恐成最大赢家 哈哈哈]Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly ...原创 2018-09-03 12:02:03 · 96 阅读 · 0 评论 -
[leetcode]526. Beautiful Arrangement
[leetcode]526. Beautiful ArrangementAnalysis 心疼奶茶妹妹~—— [马云爸爸恐成最大赢家 哈哈哈]Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N...原创 2018-09-03 15:09:50 · 109 阅读 · 0 评论 -
565. Array Nesting
565. Array NestingAnalysis 中午吃啥~—— [ummmm~]A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]],...原创 2018-09-09 10:58:15 · 110 阅读 · 0 评论 -
22. Generate Parentheses
22. Generate ParenthesesAnalysis 中午吃啥~—— [ummmm~]Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. 递归实现~Implementclass Solution {...原创 2018-09-09 16:40:25 · 68 阅读 · 0 评论 -
[leetcode]712. Minimum ASCII Delete Sum for Two Strings
[leetcode]712. Minimum ASCII Delete Sum for Two StringsAnalysis new plan~—— [好好养生啊!!]Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. 显...原创 2018-09-06 19:33:07 · 71 阅读 · 0 评论 -
[leetcode]462. Minimum Moves to Equal Array Elements II
[leetcode]462. Minimum Moves to Equal Array Elements IIAnalysis new plan~—— [好好养生啊!!]Given a non-empty integer array, find the minimum number of moves required to make all array elements e...原创 2018-09-06 19:51:22 · 92 阅读 · 0 评论 -
[leetcode]238. Product of Array Except Self
[leetcode]238. Product of Array Except SelfAnalysis new plan~—— [好好养生啊!!]Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the produ...原创 2018-09-06 20:29:09 · 84 阅读 · 0 评论 -
[leetcode]495. Teemo Attacking
[leetcode]495. Teemo AttackingAnalysis new plan~—— [好好养生啊!!]In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Te...原创 2018-09-06 21:11:01 · 72 阅读 · 0 评论 -
[leetcode]547. Friend Circles
[leetcode]547. Friend CirclesAnalysis ummmmmmmmmmmmmmmmmmmmmmmmm~—— [ummmm~]There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in...原创 2018-09-10 15:58:00 · 165 阅读 · 0 评论 -
[leetcode]46. Permutations
[leetcode]46. PermutationsAnalysis ummmmmmmmmmmmmmmmmmmmmmmmm~—— [ummmm~]Given a collection of distinct integers, return all possible permutations. 求全排列的题,这篇文章里面讲的很清楚,可以参考一下:https://blog....原创 2018-09-10 16:21:48 · 81 阅读 · 0 评论 -
[leetcode]144. Binary Tree Preorder Traversal
[leetcode]144. Binary Tree Preorder TraversalAnalysis明天就是中秋节了,那就提前拜个早年吧—— [ummm~]Given a binary tree, return the preorder traversal of its nodes’ values.前序遍历二叉树,然后输出节点值。Implement/** * Defin...原创 2018-09-23 21:55:12 · 127 阅读 · 0 评论