咸鱼刷LeetCode
学习,学习
咸鱼塘塘主
我只是不想我的未来黯淡无光
展开
-
LeetCode-Java-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 nums1's elements in the corresponding places of nums2...原创 2018-09-27 14:31:58 · 307 阅读 · 0 评论 -
LeetCode-Java-492. Construct the Rectangle
题目For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose le...原创 2018-09-06 00:32:07 · 181 阅读 · 0 评论 -
LeetCode-Java-707. Design Linked List
题目Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly linked list should have two attributes: val and next. val...原创 2018-09-06 23:50:53 · 1014 阅读 · 0 评论 -
LeetCode-Java-104. Maximum Depth of Binary Tree
题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no c...原创 2018-09-14 23:34:19 · 186 阅读 · 0 评论 -
LeetCode-Java-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 representation.(Recall that the number of set bits an integ...原创 2018-09-17 19:28:19 · 240 阅读 · 0 评论 -
LeetCode-Java-897. Increasing Order Search Tree
题目Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child.Example 1:Input: [5,3,6,2,...原创 2018-09-17 20:34:22 · 660 阅读 · 2 评论 -
LeetCode-Java-575. Distribute Candies
题目Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute...原创 2018-08-29 12:19:33 · 207 阅读 · 0 评论 -
LeetCode-Java-893. Groups of Special-Equivalent Strings
题目You are given an array A of strings.Two strings S and T are special-equivalent if after any number of moves, S == T.A move consists of choosing two indices i and j with i % 2 == j % 2, and s...原创 2018-08-29 16:26:46 · 589 阅读 · 0 评论 -
LeetCode-Java-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[j]. An array A is monotone decreasing if ...原创 2018-09-03 00:34:12 · 461 阅读 · 0 评论 -
LeetCode-Java-404. Sum of Left Leaves
题目Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Retur...原创 2018-09-03 23:42:21 · 189 阅读 · 0 评论 -
LeetCode-Java-697. Degree of an Array
题目Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length...原创 2018-09-05 13:18:34 · 268 阅读 · 0 评论 -
LeetCode-Java-872. Leaf-Similar Trees
题目Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.假装有图For example, in the given tree above, the leaf value sequence i...原创 2018-08-22 12:58:34 · 227 阅读 · 2 评论 -
LeetCode-Java-766. Toeplitz Matrix
题目A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1:Input:mat...原创 2018-08-26 10:31:26 · 253 阅读 · 0 评论 -
LeetCode-Java-136. Single Number
题目Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it with...原创 2018-08-19 16:56:23 · 296 阅读 · 0 评论 -
LeetCode-SQL-620. Not Boring Movies
题目X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions.Please write a SQL query to output mo...原创 2018-08-19 14:32:45 · 225 阅读 · 0 评论 -
LeetCode-Java-559. Maximum Depth of N-ary Tree
题目Given a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example, given a 3-ary tree:...原创 2018-08-19 15:30:30 · 409 阅读 · 0 评论 -
LeetCode-Java-344. Reverse String
题目Write a function that takes a string as input and returns the string reversed.Example 1:Input: "hello"Output: "olleh"Example 2:Input: "A man, a plan, a canal: Panama"Output: "amanaP :la...原创 2018-08-19 14:18:55 · 316 阅读 · 0 评论 -
LeetCode-Java-557. 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 conte...原创 2018-08-19 13:46:10 · 325 阅读 · 0 评论 -
LeetCode-Java-821. Shortest Distance to a Character
题目Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.Example 1:Input: S = "loveleetcode", C = 'e'Output: [3,...原创 2018-08-19 13:15:31 · 326 阅读 · 0 评论 -
LeetCode-Java-884. Uncommon Words from Two Sentences
题目We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.)A word is uncommon if it appears exactly once in one of th...原创 2018-08-18 10:22:05 · 484 阅读 · 0 评论 -
LeetCode-Java-811. Subdomain Visit Count
题目A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcod...原创 2018-08-18 09:44:27 · 337 阅读 · 0 评论 -
LeetCode-Java-876. Middle of the Linked List
题目Given a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node.Example 1:Input: [1,2,3,4,5]O...原创 2018-08-02 10:02:40 · 422 阅读 · 0 评论 -
LeetCode-Java-500. 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.American keyboardrow1:qwertyuioprow2:asdfghjk...原创 2018-07-22 16:42:25 · 265 阅读 · 0 评论 -
LeetCode-Java-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 o...原创 2018-07-22 15:53:45 · 171 阅读 · 0 评论 -
LeetCode-Java-806. Number of Lines To Write String
题目We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 uni...原创 2018-07-22 14:31:46 · 197 阅读 · 0 评论 -
LeetCode-Java-868. Binary Gap
题目Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.If there aren't two consecutive 1's, return 0.Example 1:Inp...原创 2018-07-22 15:32:18 · 342 阅读 · 0 评论 -
LeetCode-Java-561. Array Partition I
题目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 a...原创 2018-07-20 20:17:14 · 225 阅读 · 0 评论 -
LeetCode-Java-709. To Lower Case
题目Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.Example 1:Input: "Hello"Output: "hello"Example 2:Input: "here"Output: "here"...原创 2018-07-19 23:13:37 · 488 阅读 · 0 评论 -
LeetCode-Java-13. Roman to Integer
题目Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-07-18 22:49:52 · 154 阅读 · 0 评论 -
LeetCode-Java-14. Longest Common Prefix
题目Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow","flight"]Ou...原创 2018-07-19 20:58:34 · 205 阅读 · 0 评论 -
LeetCode-Java-21. Merge Two Sorted Lists
题目Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Outpu...原创 2018-07-19 20:59:42 · 263 阅读 · 0 评论 -
LeetCode-Java-26. Remove Duplicates from Sorted Array
题目Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by m...原创 2018-07-19 21:01:15 · 133 阅读 · 0 评论 -
LeetCode-Java-28. Implement strStr()
题目Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Exam...原创 2018-07-19 21:02:52 · 248 阅读 · 0 评论 -
LeetCode-Java-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 ...原创 2018-07-19 21:04:06 · 233 阅读 · 0 评论 -
LeetCode-SQL-595. Big Countries
题目There is a table World+-----------------+------------+------------+--------------+---------------+| name | continent | area | population | gdp |+---------------...原创 2018-07-19 21:05:28 · 182 阅读 · 0 评论 -
LeetCode-Java-617. 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 binar...原创 2018-07-19 21:06:31 · 257 阅读 · 0 评论 -
LeetCode-SQL-627. Swap Salary
题目Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no interm...原创 2018-07-19 21:07:50 · 206 阅读 · 0 评论 -
LeetCode-Java-657. Judge Route Circle
题目Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The move sequence is represen...原创 2018-07-18 20:05:47 · 244 阅读 · 0 评论 -
LeetCode-Java-728. Self Dividing Numbers
题目A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.Also, a self-d...原创 2018-07-18 20:04:26 · 195 阅读 · 0 评论 -
LeetCode-Java-771. Jewels and Stones
题目You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of t...原创 2018-07-18 20:02:42 · 350 阅读 · 0 评论