leetcode
林林剑
这个作者很懒,什么都没留下…
展开
-
写在开始
计划从今天开始记录一下自己每天的所得以及刷过leetcode题解的想法以及转载别人的和看不懂的地方。原创 2017-06-06 22:40:45 · 107 阅读 · 0 评论 -
Leetcode500. Keyboard Row
Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below. Example 1: Input: [“Hello”, “Alaska”, “Dad”, “Peace”]原创 2017-06-14 01:23:51 · 172 阅读 · 0 评论 -
Leetcode617. Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree. T原创 2017-06-14 01:34:14 · 240 阅读 · 0 评论 -
Leetcode463. Island Perimeter
ou are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely su原创 2017-06-26 23:51:48 · 153 阅读 · 0 评论 -
Leetcode513. Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree.Example 1: Input:2/ \ 1 3Output: 1 Example 2: Input: 1 / \ 2 3 / / \4 5 6 / 7Output: 7 Note原创 2017-06-27 22:55:16 · 142 阅读 · 0 评论 -
Leetcode553. Optimal Division
Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any position to change the原创 2017-06-27 23:23:48 · 168 阅读 · 0 评论 -
Leetcode655. Print Binary Tree
Print a binary tree in an m*n 2D string array following these rules:The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number. The ro原创 2017-08-10 00:00:51 · 607 阅读 · 0 评论 -
Leetcode654. Maximum Binary Tree
Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the maximum tree constructed from原创 2017-08-09 23:57:41 · 1047 阅读 · 0 评论 -
Leetcode653. Two Sum IV - Input is a BST
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1: Input: 5 / \ 3 6 / \ \原创 2017-08-09 23:54:47 · 229 阅读 · 0 评论 -
Leetcode211. Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a原创 2017-07-28 21:21:13 · 213 阅读 · 0 评论 -
Leetcode98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The right原创 2017-07-28 22:03:00 · 147 阅读 · 0 评论 -
Leetcode197. Rising Temperature
Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates.+———+————+——————+ | Id(INT) | Date(DATE) | Temperature(INT) | +———原创 2017-07-14 00:20:56 · 284 阅读 · 0 评论 -
Leetcode183. Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.Table: Customers.+—-+——-+ | Id | Name | +—-+——-原创 2017-07-03 00:10:59 · 222 阅读 · 0 评论 -
leetcode461. 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,原创 2017-06-06 22:50:18 · 129 阅读 · 0 评论 -
leetcode537. Complex Number Multiplication
Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1+1i", "1+1i"O原创 2017-06-06 23:51:40 · 191 阅读 · 0 评论 -
leetcode476. 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 32-b原创 2017-06-07 23:59:26 · 117 阅读 · 0 评论 -
leetcode557. Reverse Words in a String III
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1: Input: “Let’s take LeetCode contest” Out原创 2017-06-08 00:11:00 · 171 阅读 · 0 评论 -
leetcode566. 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 data.You’re given a matrix represented by a two-dimensio原创 2017-06-08 23:39:47 · 176 阅读 · 0 评论 -
Leetcode485. Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s.原创 2017-06-29 23:32:54 · 130 阅读 · 0 评论 -
Leetcode442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space原创 2017-06-30 00:14:02 · 167 阅读 · 0 评论 -
Leetcode413. Arithmetic Slices
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:1,原创 2017-06-30 00:35:30 · 133 阅读 · 0 评论 -
Leetcode412. 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 number and for the multiples of five output “Buzz”. For n原创 2017-06-23 00:38:43 · 195 阅读 · 0 评论 -
Leetcode182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+—-+———+ | Id | Email | +—-+———+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | +—-+———+ For example, your query shou原创 2017-07-02 23:45:20 · 155 阅读 · 0 评论 -
Leetcode99. Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space is pretty straight forward. Could you devise a const原创 2017-07-29 08:29:37 · 191 阅读 · 0 评论