LeetCode
文章平均质量分 54
user_name_is_so_long
这个作者很懒,什么都没留下…
展开
-
[LeetCode] 167.Two Sum II - Input array is sorted
[LeetCode] 167.Two Sum II - Input array is sorted题目描述解题思路实验代码题目描述Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target nu原创 2017-12-19 12:31:14 · 166 阅读 · 0 评论 -
[LeetCode] 26.Remove Duplicates from Sorted Array
[LeetCode] 26.Remove Duplicates from Sorted Array题目描述解题思路实验代码题目描述Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not alloca原创 2017-12-07 14:24:58 · 168 阅读 · 0 评论 -
[LeetCode] 27.Remove Element
[LeetCode] 27.Remove Element题目描述解题思路实验代码题目描述Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must原创 2017-11-28 00:18:28 · 158 阅读 · 0 评论 -
[LeetCode] 35.Search Insert Position
[LeetCode] 35.Search Insert Position题目描述解题思路实验代码题目描述Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted原创 2017-12-06 09:26:37 · 183 阅读 · 0 评论 -
[LeetCode] 669.Trim a Binary Search Tree
[LeetCode] 669.Trim a Binary Search Tree题目描述解题思路实验代码题目描述Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L).原创 2017-12-13 03:08:27 · 213 阅读 · 0 评论 -
[LeetCode] 9.Palindrome Number
[LeetCode] 9.Palindrome Number题目描述解题思路实验代码题目描述Determine whether an integer is a palindrome. Do this without extra space.解题思路题目很简单:判断一个整数是否为回文数。那么首先要明白一个概念,什么是回文数:设n是一任意自然数。若将n的各位数字反向排列所得自然数n1与n相等,则原创 2017-11-22 04:41:54 · 409 阅读 · 0 评论 -
[LeetCode] 1.Two Sum
[LeetCode] 1.Two Sum题目描述解题思路实验代码题目描述Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one so原创 2017-11-15 04:37:01 · 167 阅读 · 0 评论 -
[LeetCode] 637.Average of Levels in Binary Tree
[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. Example: Input:原创 2017-11-08 15:51:09 · 176 阅读 · 0 评论 -
[LeetCode] 538.Convert BST to Greater Tree
[LeetCode] 538.Convert BST to Greater Tree题目描述解题思路实验代码题目描述Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus原创 2017-10-28 17:00:06 · 190 阅读 · 0 评论 -
[LeetCode] 476.Number Complement
[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: 1. The given原创 2017-10-05 16:53:15 · 198 阅读 · 0 评论 -
[LeetCode] 595.Big Countries
[LeetCode] 595.Big Countries题目描述解题思路实验代码题目描述There is a table World name continent area population gdp Afghanistan Asia 652230 25500100 20343000 Albania Europe 28748 28317原创 2017-12-07 15:06:58 · 225 阅读 · 0 评论 -
[LeetCode] 728.Self Dividing Numbers
[LeetCode] 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,原创 2017-12-07 15:32:11 · 452 阅读 · 0 评论 -
[LeetCode] 111.Minimum Depth of Binary Tree
[LeetCode] 111.Minimum Depth of Binary Tree题目描述解题思路实验代码题目描述Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to th原创 2017-12-27 07:55:04 · 201 阅读 · 0 评论 -
[Algorithm] Chapter 8_8.3
[Algorithm] Chapter 8_8.3题目描述解答过程题目描述STINGY SAT is th following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k var原创 2017-12-31 11:31:14 · 324 阅读 · 0 评论 -
[LeetCode] 620.Not Boring Movies
[LeetCode] 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 descri原创 2017-12-08 10:11:22 · 271 阅读 · 0 评论 -
[LeetCode] 500.Keyboard Row
[LeetCode] 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.Example:原创 2017-12-08 09:38:02 · 200 阅读 · 0 评论 -
[LeetCode] 557.Reverse Words in a String III
[LeetCode] 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原创 2017-12-07 17:27:27 · 238 阅读 · 1 评论 -
[LeetCode] 461.Hamming Distance
[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, calcula原创 2017-12-07 16:53:21 · 208 阅读 · 0 评论 -
[LeetCode] 627.Swap Salary
[LeetCode] 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) w原创 2017-12-07 16:29:40 · 207 阅读 · 0 评论 -
[LeetCode] 617.Merge Two Binary Trees
[LeetCode] 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原创 2017-12-07 16:20:26 · 174 阅读 · 0 评论 -
[LeetCode] 657.Judge Route Circle
[LeetCode] 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原创 2017-12-07 15:44:25 · 297 阅读 · 0 评论 -
[LeetCode] 453.Minimum Moves to Equal Array Elements
[LeetCode] 453.Minimum Moves to Equal Array Elements题目描述解题思路实验代码题目描述Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a mo原创 2017-10-20 01:46:13 · 177 阅读 · 0 评论 -
[LeetCode] 448.Find All Numbers Disappeared in an Array
[LeetCode] 448.Find All Numbers Disappeared in an Array题目描述解题思路实验代码题目描述Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all原创 2017-10-10 18:22:53 · 245 阅读 · 0 评论 -
[LeetCode] 13.Roman to Integer
[LeetCode] 13.Roman to Integer罗马数字与阿拉伯数字的关系罗马数字的组数规则题目描述解题思路实验代码罗马数字与阿拉伯数字的关系 基本字符 相应的阿拉伯数字 I 1 V 5 X 10 L 50 C 100 D 500 M 1000罗马数字的组数规则1.基本数字 Ⅰ、X 、C 中的任何一个、自身连用构原创 2017-09-11 00:11:49 · 175 阅读 · 0 评论 -
[LeetCode] 12.Integer to Roman
[LeetCode] 12.Integer to Roman罗马数字与阿拉伯数字的关系罗马数字的组数规则题目描述解题思路实验代码罗马数字与阿拉伯数字的关系 基本字符 相应的阿拉伯数字 I 1 V 5 X 10 L 50 C 100 D 500 M 1000罗马数字的组数规则1.基本数字 Ⅰ、X 、C 中的任何一个、自身连用构原创 2017-09-11 00:17:08 · 173 阅读 · 0 评论 -
[LeetCode] 371.Sum of Two Integers
[LeetCode] 371.Sum of Two Integers题目描述解题思路实验代码题目描述Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.解题思路这道题目考察原创 2017-09-17 02:54:18 · 243 阅读 · 0 评论 -
[LeetCode] 389.Find the Difference
[LeetCode] 389.Find the Difference题目描述解题思路实验代码题目描述Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter a原创 2017-09-17 02:36:04 · 175 阅读 · 0 评论 -
[LeetCode] 145.Binary Tree Postorder Traversal
[LeetCode] 145.Binary Tree Postorder Traversal题目描述解题思路实验代码题目描述Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2原创 2017-09-17 02:07:30 · 258 阅读 · 0 评论 -
[LeetCode] 144.Binary Tree Preorder Traversal
[LeetCode] 144.Binary Tree Preorder Traversal题目描述解题思路实验代码题目描述Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2原创 2017-09-17 01:59:28 · 181 阅读 · 0 评论 -
[LeetCode] 101.Symmetric Tree
[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原创 2017-09-17 01:42:03 · 193 阅读 · 0 评论 -
[LeetCode] 100.Same Tree
[LeetCode] 100.Same Tree题目描述解题思路实验代码题目描述Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the n原创 2017-09-16 11:44:58 · 249 阅读 · 0 评论 -
[LeetCode] 520.Detect Capital
[LeetCode] 520.Detect Capital题目描述解题思路实验代码题目描述Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of th原创 2017-09-27 02:02:09 · 170 阅读 · 0 评论 -
[LeetCode] 541.Reverse String II
[LeetCode] 541.Reverse String II题目描述解题思路实验代码题目描述Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there a原创 2017-09-27 02:19:46 · 237 阅读 · 0 评论 -
[LeetCode] 434.Number of Segments in a String
[LeetCode] 434.Number of Segments in a String题目描述解题思路实验代码题目描述Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note tha原创 2017-10-10 17:39:08 · 180 阅读 · 0 评论 -
[LeetCode] 404.Sum of Left Leaves
[LeetCode] 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 t原创 2017-10-10 17:20:15 · 199 阅读 · 0 评论 -
[LeetCode] 405.Convert a Number to Hexadecimal
[LeetCode] 405.Convert a Number to Hexadecimal题目描述解题思路实验代码题目描述Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.Note: 1. All原创 2017-10-10 14:54:47 · 165 阅读 · 0 评论 -
[LeetCode] 58.Length of Last Word
[LeetCode] 58.Length of Last Word题目描述解题思路实验代码题目描述Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string.If the last wor原创 2017-09-17 11:02:51 · 220 阅读 · 0 评论 -
[LeetCode] 412.Fizz Buzz
[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 number and fo原创 2017-09-17 03:12:34 · 321 阅读 · 0 评论 -
[LeetCode] 561.Array Partition I
[LeetCode] 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 m原创 2017-09-21 07:51:45 · 269 阅读 · 0 评论 -
[LeetCode] 415.Add Strings
[LeetCode] 415.Add Strings题目描述解题思路实验代码题目描述Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note: 1. The length of both num1 and num2 is < 5100.原创 2017-09-27 03:07:19 · 220 阅读 · 0 评论