- 博客(20)
- 收藏
- 关注
原创 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 231
原创 [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 289
原创 [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 257
原创 [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 243
原创 [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 261
原创 [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 209
原创 [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 342
原创 快速排序的两种实现思路和非递归实现--C++实现
思路一: 第一种是根据算法导论上的思想:取数组的最后一个元素为主元,i初始化为最低位元素的前一个位置,j指向遍历数组中待排序的元素,当j所指元素比主元小的时候i= i + 1,然后交换i和j所指的元素,j不断遍历,遇到小于主元的就进行交换,这样就能一直维持这样一个序列,i之前的元素(包括i所指元素本身)都是比主元小的元素,i到j之间都是比主元大的元素,j(包括j所指元素)之后都是待排
2016-09-14 15:00:52 6274
原创 [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 324
原创 [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 197
原创 [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 162
原创 [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 153
原创 [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 177
原创 [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 185
原创 [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 190
原创 [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 209
转载 c++ 模板类 声明和定义都放在.h文件的原因
首先,一个编译单元(translation unit)是指一个.cpp文件以及它所#include的所有.h文件,.h文件里的代码将会被扩展到包含它的.cpp文件里,然后编译器编译该.cpp文件为一个.obj文件(假定我们的平台是win32),后者拥有PE(Portable Executable,即windows可执行文件)文件格式,并且本身包含的就已经是二进制码,但是不一定能够执行,因为并不保
2016-08-31 22:31:21 652 1
原创 [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 197
原创 [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 286
原创 [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 401
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人