- 博客(13)
- 收藏
- 关注
原创 [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 275
原创 [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 279
原创 [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 291
原创 [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 246
原创 [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 372
原创 快速排序的两种实现思路和非递归实现--C++实现
思路一: 第一种是根据算法导论上的思想:取数组的最后一个元素为主元,i初始化为最低位元素的前一个位置,j指向遍历数组中待排序的元素,当j所指元素比主元小的时候i= i + 1,然后交换i和j所指的元素,j不断遍历,遇到小于主元的就进行交换,这样就能一直维持这样一个序列,i之前的元素(包括i所指元素本身)都是比主元小的元素,i到j之间都是比主元大的元素,j(包括j所指元素)之后都是待排
2016-09-14 15:00:52 6334
原创 [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 337
原创 [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 213
原创 [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 171
原创 [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 164
原创 [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 189
原创 [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 200
原创 [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 202
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人