LeetCode
sqyx008
这个作者很懒,什么都没留下…
展开
-
LeetCode 55. Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.原创 2017-07-18 20:39:03 · 400 阅读 · 0 评论 -
LeetCode 263. Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.原创 2017-04-04 09:23:50 · 194 阅读 · 0 评论 -
LeetCode 367. Valid Perfect Square
Given a positive integer num, write a function which returns True if num is a perfect square else False.原创 2017-04-04 09:08:23 · 245 阅读 · 0 评论 -
LeetCode 374. Guess Number Higher or Lower
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked.原创 2017-04-04 08:45:18 · 215 阅读 · 0 评论 -
LeetCode 383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines.原创 2017-04-04 08:16:11 · 300 阅读 · 0 评论 -
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.原创 2017-04-04 08:08:11 · 209 阅读 · 0 评论 -
LeetCode 20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.原创 2017-04-03 22:35:24 · 159 阅读 · 0 评论 -
LeetCode 198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed原创 2017-03-27 14:13:05 · 298 阅读 · 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.原创 2017-03-27 12:00:53 · 162 阅读 · 0 评论 -
LeetCode 242. Valid Anagram
Given two strings ss and tt, write a function to determine if t is an anagram of s.原创 2017-03-27 09:12:15 · 146 阅读 · 0 评论 -
LeetCode 171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.原创 2017-03-27 09:03:32 · 176 阅读 · 0 评论 -
LeetCode 67. Add Binary
Given two binary strings, return their sum (also a binary string).原创 2017-04-03 22:02:25 · 162 阅读 · 0 评论 -
LeetCode 404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree.原创 2017-03-27 01:31:52 · 262 阅读 · 0 评论 -
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.原创 2017-04-03 09:58:38 · 208 阅读 · 0 评论 -
LeetCode 238. Product of Array Except Self
Given an array of nn integers where n>1n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].原创 2017-03-26 17:54:56 · 182 阅读 · 0 评论 -
LeetCode 189. Rotate Array
Rotate an array of n elements to the right by k steps.原创 2017-04-04 11:07:20 · 204 阅读 · 0 评论 -
LeetCode 551. Student Attendance Record I
DescriptionYou are given a string representing an attendance record for a student. The record only contains the following three characters:‘A’ : Absent.‘L’ : Late.‘P’ : Present.A student could be r原创 2017-04-17 17:11:21 · 516 阅读 · 0 评论 -
LeetCode 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.原创 2017-04-17 23:28:20 · 343 阅读 · 0 评论 -
LeetCode 643. Maximum Average Subarray I
Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.原创 2017-07-21 19:38:34 · 579 阅读 · 0 评论 -
LeetCode 633. Sum of Square Numbers
Given a non-negative integer c, your task is to decide whether there’re two integers a and b such that a2+b2=ca^2 + b^2 = c.原创 2017-07-15 10:28:01 · 279 阅读 · 0 评论 -
LeetCode 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.原创 2017-04-27 12:45:20 · 459 阅读 · 0 评论 -
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 min(ai, bi) for all i from 1 to n as large as possible.原创 2017-04-26 08:35:29 · 646 阅读 · 0 评论 -
LeetCode 258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.原创 2017-04-23 15:53:11 · 427 阅读 · 0 评论 -
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 nodes have the same value.原创 2017-04-23 10:42:33 · 298 阅读 · 0 评论 -
LeetCode 217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates.原创 2017-04-22 12:00:18 · 222 阅读 · 0 评论 -
LeetCode 283. Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.原创 2017-04-22 11:34:50 · 237 阅读 · 0 评论 -
LeetCode 73. Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.原创 2017-04-22 11:27:02 · 235 阅读 · 0 评论 -
LeetCode 521. Longest Uncommon Subsequence I
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings.原创 2017-04-16 10:54:55 · 428 阅读 · 0 评论 -
LeetCode 396. Rotate Function
Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise原创 2017-04-05 20:20:50 · 218 阅读 · 0 评论 -
LeetCode 191. Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of'1'bits it has (also known as the Hamming weight).原创 2017-04-05 19:13:23 · 206 阅读 · 0 评论 -
LeetCode 338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.原创 2017-04-28 15:17:23 · 287 阅读 · 0 评论 -
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 in order.原创 2017-04-17 23:52:00 · 339 阅读 · 0 评论 -
LeetCode 122. Best Time to Buy and Sell Stock II
Say you have an array for which the ithi^{th} element is the price of a given stock on day ii.Design an algorithm to find the maximum profit. You may complete as many transactions as you like原创 2017-04-03 00:10:31 · 181 阅读 · 0 评论 -
LeetCode 7. Reverse Integer
Reverse digits of an integer.原创 2017-04-02 22:29:31 · 147 阅读 · 0 评论 -
LeetCode 70. Climbing Stairs
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 word does not exist, return 0.原创 2017-03-29 19:34:12 · 194 阅读 · 0 评论 -
LeetCode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).原创 2017-04-07 12:48:48 · 208 阅读 · 0 评论 -
LeetCode 36. Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.原创 2017-03-28 21:42:47 · 199 阅读 · 0 评论 -
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 word does not exist, return 0.原创 2017-03-28 20:52:11 · 163 阅读 · 0 评论 -
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 number.原创 2017-03-28 19:53:00 · 188 阅读 · 0 评论 -
LeetCode 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.原创 2017-03-28 19:14:17 · 189 阅读 · 0 评论