LeetCode
CodePikachu
这个作者很懒,什么都没留下…
展开
-
[leetcode] 1. Two Sum
1. Two SumGiven 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.Example: Given nums原创 2016-08-26 20:36:30 · 404 阅读 · 0 评论 -
[leetcode] 18. 4Sum
18. 4SumGiven an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solutio原创 2016-09-26 14:52:04 · 263 阅读 · 0 评论 -
[leetcode] 15. 3Sum
15. 3Sum Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not cont原创 2016-09-26 09:53:37 · 249 阅读 · 0 评论 -
[leetcode] 167. Two Sum II - Input array is sorted
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.The function twoSum sho原创 2016-09-24 21:10:16 · 265 阅读 · 0 评论 -
[leetcode] 1. Two Sum
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.Example:Given nums =原创 2016-09-24 16:20:28 · 215 阅读 · 0 评论 -
[leetcode] 42. Trapping Rain Water
42. Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,原创 2016-10-09 20:26:49 · 293 阅读 · 0 评论 -
[leetcode] 217. Contains Duplicate
217. Contains DuplicateGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return fal原创 2016-09-06 14:57:33 · 181 阅读 · 0 评论 -
[leetcode] 171. Excel Sheet Column Number
171. Excel Sheet Column NumberRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z原创 2016-09-03 12:39:59 · 190 阅读 · 0 评论 -
[leetcode] 319. Bulb Switcher
319. Bulb Switcher There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s原创 2016-09-17 11:31:05 · 356 阅读 · 0 评论 -
[leetcode] 169. Majority Element
169. Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the m原创 2016-09-03 12:03:55 · 191 阅读 · 0 评论 -
[leetcode] 283. Move Zeroes
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原创 2016-08-30 22:37:43 · 199 阅读 · 0 评论 -
[leetcode] 260. Single Number III
260. Single Number III Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For原创 2016-09-12 16:55:44 · 329 阅读 · 0 评论 -
[leetcode] 168. Excel Sheet Column Title
168. Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27原创 2016-08-31 22:43:29 · 211 阅读 · 0 评论 -
[leetcode] 258. Add Digits
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 has原创 2016-09-12 16:31:27 · 202 阅读 · 0 评论 -
[leetcode] 242. Valid Anagram
242. Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note:原创 2016-09-12 16:21:41 · 163 阅读 · 0 评论 -
[leetcode] 238. Product of Array Except Self
238. Product of Array Except Self Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve i原创 2016-09-12 16:00:42 · 155 阅读 · 0 评论 -
[leetcode] 136. Single Number
136 Single NumberGiven an 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 witho原创 2016-08-29 17:51:32 · 289 阅读 · 0 评论 -
18. 4Sum
18. 4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target ? Find all unique quadruplets in the array which gives the sum of target. No原创 2017-06-20 22:54:52 · 233 阅读 · 0 评论