
LeetCode算法(C++)
文章平均质量分 73
BigoSprite
这个作者很懒,什么都没留下…
展开
-
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原创 2016-03-20 17:53:40 · 403 阅读 · 0 评论 -
80. Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array II Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your func翻译 2016-05-02 22:25:15 · 290 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for anoth原创 2016-05-02 17:31:46 · 311 阅读 · 0 评论 -
将6个字符串存入vector容器中,并采用一种STL算法排序并输出
将6个字符串存入vector容器中,并采用一种STL算法排序并输出#include #include #include #include #include #include #include using namespace std;void main(){ vector coll{"asayjk", "bhjresaf", "cebnmr", "dttzlo",原创 2016-04-15 12:52:33 · 3271 阅读 · 1 评论 -
202. Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares原创 2016-03-27 23:58:08 · 388 阅读 · 0 评论 -
217. Contains Duplicate
Given 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 false if every element原创 2016-03-22 23:04:30 · 380 阅读 · 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 has on原创 2016-03-22 21:22:18 · 362 阅读 · 0 评论 -
228. Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].Credits:Special thanks to @jianchao.li.fighter原创 2016-03-22 17:13:24 · 484 阅读 · 0 评论 -
1. Two Sum
Two Sum Problem Definition 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 solutio原创 2016-04-03 13:30:10 · 401 阅读 · 0 评论 -
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:You may a原创 2016-03-20 22:30:36 · 294 阅读 · 0 评论 -
27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The原创 2016-05-03 16:28:43 · 340 阅读 · 0 评论