LeetCode
大炜丶
这个作者很懒,什么都没留下…
展开
-
507. Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write a function that returns true when it is a perfec原创 2017-09-04 10:17:46 · 162 阅读 · 0 评论 -
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 solution, and you may not use the same原创 2017-09-18 09:03:30 · 324 阅读 · 0 评论 -
599. Minimum Index Sum of Two Lists
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with th原创 2017-08-24 10:08:15 · 307 阅读 · 0 评论 -
122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one原创 2017-08-22 09:45:24 · 229 阅读 · 0 评论 -
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. For example, given nums = [0, 1, 0, 3, 12], after calling you原创 2017-08-21 09:08:29 · 138 阅读 · 0 评论 -
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 at a random position. Find the letter that was原创 2017-08-18 10:42:05 · 175 阅读 · 0 评论 -
258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2原创 2017-08-14 09:12:41 · 174 阅读 · 0 评论 -
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. Answer: public class Solution {原创 2017-08-14 09:11:39 · 151 阅读 · 0 评论 -
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 the elements of [1, n] inclusive that do not appear in this array.原创 2017-08-14 09:10:35 · 159 阅读 · 0 评论 -
344. Reverse String
Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". Answer: public class Solution { public String reverseS原创 2017-08-14 09:06:25 · 161 阅读 · 0 评论 -
595. Big Countries
There is a table World +-----------------+------------+------------+--------------+---------------+ | name | continent | area | population | gdp | +-----------------+---原创 2017-08-14 09:02:10 · 336 阅读 · 0 评论 -
342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without原创 2017-08-29 14:38:48 · 177 阅读 · 0 评论