
LeedCode365
Simple_ R
这个作者很懒,什么都没留下…
展开
-
5051. Valid Boomerang
Aboomerangis a set of 3 points that are all distinct andnotin a straight line.Given a listof three points in the plane, return whether these points are a boomerang.Example 1:Input: [[1...原创 2019-05-05 11:42:46 · 369 阅读 · 0 评论 -
Leetcode 409. Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not cons...原创 2019-02-18 10:00:25 · 307 阅读 · 0 评论 -
Leetcode 401. Binary Watch
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant bit on...原创 2019-02-17 23:33:04 · 173 阅读 · 0 评论 -
Leetcode 993. Cousins in Binary Tree
In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.Two nodes of a binary tree are cousins if they have the same depth, but have different parents.We...原创 2019-02-17 12:13:52 · 457 阅读 · 0 评论 -
Leetcode 461. 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 < 2...原创 2019-02-16 15:55:17 · 215 阅读 · 0 评论 -
Leetcode 985. Sum of Even Numbers After Queries
We have an array A of integers, and an array queries of queries.For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index]. Then, the answer to the i-th query is the sum...原创 2019-02-03 18:27:59 · 456 阅读 · 0 评论 -
Leetcode 112. Path Sum
Related tops: DFS & RecursionGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf i...原创 2019-01-28 12:05:56 · 153 阅读 · 0 评论 -
Leetcode 984. String Without AAA or BBB
贪心算法Given two integers A and B, return any string S such that:S has length A + B and contains exactly A 'a' letters, and exactly B 'b'letters; The substring 'aaa' does not occur in S; The subst...原创 2019-01-27 22:57:30 · 372 阅读 · 0 评论 -
Leetcode 561. Array Partition
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as pos...原创 2019-01-27 21:45:35 · 172 阅读 · 0 评论 -
Leetcode 784. Letter Case Permutation
backtracking + dfs + recursive 784. Letter Case PermutationEasy49661FavoriteShareGiven a string S, we can transform every letter individually to be lowercase or uppercase to create another st...原创 2019-01-27 19:29:45 · 177 阅读 · 0 评论 -
Leetcode 856. Score of Parentheses
递归专题1Given a balanced parentheses string S, compute the score of the string based on the following rule:() has score 1 AB has score A + B, where A and B are balanced parentheses strings. (A) h...原创 2019-01-27 17:33:23 · 384 阅读 · 2 评论 -
Leetcode 982. Triples with Bitwise AND Equal To Zero
Given an array of integers A, find the number of triples of indices (i, j, k) such that:0 <= i < A.length 0 <= j < A.length 0 <= k < A.length A[i] & A[j] & A[k] == 0, w...原创 2019-01-27 12:54:14 · 507 阅读 · 0 评论 -
Leetcode 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are de...原创 2019-01-25 23:49:30 · 143 阅读 · 0 评论 -
525. 连续数组
https://leetcode-cn.com/problems/contiguous-array/ 给定一个二进制数组, 找到含有相同数量的 0 和 1 的最长连续子数组(的长度)。 示例 1:输入: [0,1]输出: 2说明: [0, 1] 是具有相同数量0和1的最长连续子数组。示例 2:输入: [0,1,0]输出: 2说明: [0, 1] (或 [1, ...原创 2019-01-10 00:51:13 · 259 阅读 · 0 评论 -
Leetcode 77. Combinations
todo原创 2019-01-20 13:04:14 · 167 阅读 · 0 评论 -
Leetcode 977. Squares of a Sorted Array
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1:Input: [-4,-1,0,3,10]Output: [0,1,9,...原创 2019-01-20 12:05:38 · 641 阅读 · 0 评论 -
Leetcode 997. Find the Town Judge
In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge.If the town judge exists, then:The town judge trusts nobody. Everybody (...原创 2019-02-24 11:57:37 · 496 阅读 · 0 评论 -
Leetcode 1002. Find Common Characters
Given an arrayAof strings made only from lowercase letters, return a list of all characters that show up in all strings within the list(including duplicates).For example, if a character occurs 3...原创 2019-03-03 12:23:42 · 721 阅读 · 0 评论 -
Leetcode 1021. Remove Outermost Parentheses
A valid parentheses string is either empty(""),"(" + A + ")", orA + B, whereAandBare valid parentheses strings, and+represents string concatenation. For example,"","()","(())()", and"(()...原创 2019-04-07 13:13:40 · 416 阅读 · 0 评论 -
Leetcode 1028. Convert to Base -2
Given a numberN, return a string consisting of"0"s and"1"sthat represents its value in base-2(negative two).The returned string must have no leading zeroes, unless the string is"0".Exam...原创 2019-03-31 18:05:14 · 310 阅读 · 0 评论 -
Leetcode 1030. Next Greater Node In Linked List
We are given a linked list withheadas the first node. Let's number thenodes in the list:node_1, node_2, node_3, ...etc.Each node may have anext largervalue: fornode_i,next_larger(node_i)...原创 2019-03-31 13:32:16 · 285 阅读 · 0 评论 -
Leetcode 1029. Binary Prefix Divisible By 5
Given an arrayAof0s and1s, considerN_i: the i-th subarray fromA[0]toA[i]interpretedas a binary number (from most-significant-bit to least-significant-bit.)Return a list of booleansanswer...原创 2019-03-31 13:31:20 · 344 阅读 · 0 评论 -
1023. Binary String With Substrings Representing 1 To N
Given a binary stringS(a string consisting only of '0' and '1's) and a positive integerN, return true if and only if for every integer X from 1 to N, the binary representation of X is a substring ...原创 2019-03-24 11:11:05 · 421 阅读 · 0 评论 -
Leetcode 114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \ ...原创 2019-03-30 16:32:20 · 196 阅读 · 0 评论 -
Leetcode 476. Number Complement
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within the range of a ...原创 2019-03-30 14:20:25 · 178 阅读 · 0 评论 -
Leetcode 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the linked list where tail c...原创 2019-03-24 22:03:29 · 167 阅读 · 0 评论 -
Leetcode 438. Find All Anagrams in a String
Given a stringsand anon-emptystringp, find all the start indices ofp's anagrams ins.Strings consists of lowercase English letters only and the length of both stringssandpwill not be larg...原创 2019-03-12 23:43:30 · 337 阅读 · 1 评论 -
Leetcode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree[1,2,2,3,4,4,3]is symmetric: 1 / \ 2 2 / \ / \3 4 4 3...原创 2019-03-17 23:47:13 · 160 阅读 · 0 评论 -
Leetcode 1013. Pairs of Songs With Total Durations Divisible by 60
In a list of songs, thei-thsong has a duration oftime[i]seconds.Return the number of pairs of songs for which their totalduration in seconds is divisible by60. Formally, we want the number ...原创 2019-03-17 22:29:33 · 231 阅读 · 0 评论 -
Leetcode 1012. Complement of Base 10 Integer
Every non-negative integerNhas a binary representation. For example,5can be represented as"101"in binary,11as"1011"in binary, and so on. Note that except forN = 0, there are no leading z...原创 2019-03-17 12:16:34 · 207 阅读 · 0 评论 -
Leetcode 400. Nth Digit
Find thenthdigit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:nis positive and will fit within the range of a 32-bit signed integer (n< 231).Example 1:Inp...原创 2019-03-16 00:51:17 · 154 阅读 · 0 评论 -
Leetcode 1005. Maximize Sum Of Array After K Negations
Given an arrayAof integers, wemustmodify the array in the following way: we choose aniand replaceA[i]with-A[i], and we repeat this processKtimes in total. (We may choose the same indexi...原创 2019-03-10 12:58:32 · 323 阅读 · 0 评论 -
Leetcode 1003. Check If Word Is Valid After Substitutions
We are given that the string"abc"is valid.From any valid stringV, we may splitVinto two piecesXandYsuch thatX + Y(Xconcatenated withY) is equal toV. (XorYmay be empty.) Then,X + ...原创 2019-03-03 12:24:51 · 412 阅读 · 0 评论 -
Leetcode 978. Longest Turbulent Subarray
A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if:For i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k is even; OR, for i <= k < j, ...原创 2019-01-20 12:04:26 · 298 阅读 · 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 impossible to form any triangle of non-zero area, return...原创 2019-01-13 12:17:53 · 282 阅读 · 0 评论 -
929. Unique Email Addresses
Every email consists of a local name and a domain name, separated by the @ sign.For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.Besides lowercase l...原创 2018-10-28 11:48:36 · 440 阅读 · 0 评论 -
915. Partition Array into Disjoint Intervals
Given an array A, partition it into two (contiguous) subarrays left and right so that:Every element in left is less than or equal to every element in right. left and right are non-empty. left has ...原创 2018-09-30 15:58:42 · 244 阅读 · 0 评论 -
914. X of a Kind in a Deck of Cards
In a deck of cards, each card has an integer written on it.Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where...原创 2018-09-30 12:49:00 · 453 阅读 · 0 评论 -
763. Partition Labels
A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing th...原创 2018-09-29 13:06:05 · 148 阅读 · 0 评论 -
268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.Example 1:Input: [3,0,1]Output: 2Example 2:Input: [9,6,4,2,3,5,7,0,1]O...原创 2018-10-07 22:19:47 · 106 阅读 · 0 评论