C++
文章平均质量分 58
makuiyu
这个作者很懒,什么都没留下…
展开
-
C++ 空类默认产生的类成员函数
C++的空类有哪些成员函数:. 缺省构造函数。. 缺省拷贝构造函数。. 缺省析构函数。. 缺省赋值运算符。. 缺省取址运算符。. 缺省取址运算符 const。 注意:有些书上只是简单的介绍了前四个函数。没有提及后面这两个函数。但后面这两个函数也是空类的默认函数。另外需要注意的是,只有当实际使用这些函数的时候,编译器才会去定义它们。//C++ 空原创 2012-10-08 10:54:00 · 8899 阅读 · 0 评论 -
LeetCode --- 2. Add Two Numbers
题目链接:Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers a原创 2015-01-27 22:21:25 · 759 阅读 · 0 评论 -
LeetCode --- 1. Two Sum
题目链接:[Two Sum](https://oj.leetcode.com/problems/two-sum/ )Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of th原创 2015-01-27 22:08:03 · 825 阅读 · 0 评论 -
LeetCode --- 5. Longest Palindromic Substring
题目链接:Longest Palindromic SubstringGiven a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic原创 2015-01-27 22:25:13 · 1130 阅读 · 0 评论 -
LeetCode --- 3. Longest Substring Without Repeating Characters
题目链接:Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters原创 2015-01-27 22:24:17 · 773 阅读 · 0 评论 -
LeetCode --- 4. Median of Two Sorted Arrays
题目链接:Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).这原创 2015-01-27 22:24:48 · 705 阅读 · 0 评论 -
LeetCode --- 6. ZigZag Conversion
题目链接:ZigZag ConversionThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)原创 2015-01-28 13:04:40 · 758 阅读 · 0 评论 -
LeetCode --- 7. Reverse Integer
题目链接:Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bo原创 2015-01-28 13:05:36 · 748 阅读 · 0 评论 -
LeetCode --- 8. String to Integer (atoi)
题目链接:String to Integer (atoi)Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself w原创 2015-01-28 13:07:01 · 699 阅读 · 0 评论 -
LeetCode --- 9. Palindrome Number
题目链接:Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the原创 2015-01-28 19:55:13 · 795 阅读 · 0 评论 -
LeetCode --- 11. Container With Most Water
题目链接:Container With Most WaterGiven n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is原创 2015-01-29 10:49:05 · 3174 阅读 · 1 评论 -
LeetCode --- 13. Roman to Integer
题目链接:Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.这道题的要求是将罗马数字转化成整数,其中输入数据范围是1到3999。罗马数字是最早的数字表示方式,比阿拉伯数字早2000多年,起源原创 2015-01-29 10:50:24 · 791 阅读 · 0 评论 -
LeetCode --- 14. Longest Common Prefix
题目链接:Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.这道题的要求是在字符串数组中找到最长公共前缀。思路比较简单,就是两个字符串逐个比较,找最长公共子串。这里采用将每个字符串都与第一个字符串相比较,求最长子串。时间原创 2015-01-29 19:37:35 · 773 阅读 · 0 评论 -
LeetCode --- 10. Regular Expression Matching
题目链接:Regular Expression MatchingImplement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The match原创 2015-01-28 19:56:22 · 807 阅读 · 0 评论 -
LeetCode --- 12. Integer to Roman
题目链接:Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.这道题的要求是将整数转化成罗马数字,其中输入数据范围是1到3999。罗马数字是最早的数字表示方式,比阿拉伯数字早2000多年,起源原创 2015-01-29 10:49:53 · 2904 阅读 · 0 评论 -
LeetCode --- 21. Merge Two Sorted Lists
题目链接:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.这道题的要求是将两个已经排好序的链表合并成1个有序链表。原创 2015-01-31 13:07:19 · 810 阅读 · 0 评论 -
LeetCode --- 22. Generate Parentheses
题目链接:Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(原创 2015-01-31 13:08:39 · 2963 阅读 · 0 评论 -
LeetCode --- 19. Remove Nth Node From End of List
题目链接:Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2.After removing原创 2015-01-30 21:37:19 · 748 阅读 · 0 评论 -
LeetCode --- 20. Valid Parentheses
题目链接:Valid ParenthesesGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "原创 2015-01-30 21:37:57 · 744 阅读 · 0 评论 -
LeetCode --- 23. Merge k Sorted Lists
题目链接:Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.这道题的要求是将k个有序链表合并成1个有序链表,并分析其复杂度。1. 暴力合并最简单思路就是暴力合并,可以将k个链表一个接着一个地合并原创 2015-01-31 13:11:03 · 1006 阅读 · 0 评论 -
LeetCode --- 17. Letter Combinations of a Phone Number
题目链接:Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone原创 2015-01-30 21:30:34 · 3730 阅读 · 1 评论 -
LeetCode --- 16. 3Sum Closest
题目链接:3Sum ClosestGiven an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input原创 2015-01-30 21:29:23 · 875 阅读 · 0 评论 -
LeetCode --- 25. Reverse Nodes in k-Group
题目链接:Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in t原创 2015-02-01 16:57:14 · 662 阅读 · 0 评论 -
LeetCode --- 29. Divide Two Integers
题目链接:Divide Two IntegersDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.这道题的要求是在不使用乘法、除法、取模运算的前提下实现两个整数相除。如果溢出,返回MAX_INT。这道题的直接思路是原创 2015-02-02 21:58:27 · 2320 阅读 · 0 评论 -
LeetCode --- 27. Remove Element
题目链接:Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond t原创 2015-02-02 11:53:09 · 864 阅读 · 0 评论 -
LeetCode --- 30. Substring with Concatenation of All Words
题目链接:Substring with Concatenation of All WordsYou are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatena原创 2015-02-02 21:59:32 · 794 阅读 · 0 评论 -
LeetCode --- 28. Implement strStr()
题目链接:Implement strStr()Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the func原创 2015-02-02 11:54:14 · 1595 阅读 · 0 评论 -
LeetCode --- 24. Swap Nodes in Pairs
题目链接:Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use原创 2015-02-01 16:56:41 · 849 阅读 · 0 评论 -
LeetCode --- 26. Remove Duplicates from Sorted Array
题目链接:Remove Duplicates from Sorted ArrayGiven 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 ano原创 2015-02-02 11:52:37 · 2947 阅读 · 0 评论 -
LeetCode --- 31. Next Permutation
题目链接:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it a原创 2015-02-04 23:15:57 · 860 阅读 · 0 评论 -
LeetCode --- 32. Longest Valid Parentheses
题目链接:Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid paren原创 2015-02-04 23:16:46 · 2734 阅读 · 0 评论 -
LeetCode --- 34. Search for a Range
题目链接:Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the原创 2015-02-04 23:18:37 · 788 阅读 · 0 评论 -
LeetCode --- 35. Search Insert Position
题目链接:Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume原创 2015-02-04 23:19:21 · 831 阅读 · 0 评论 -
LeetCode --- 15. 3Sum
题目链接:3SumGiven 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:*Elements in a triplet (a原创 2015-01-29 19:38:27 · 2223 阅读 · 0 评论 -
LeetCode --- 18. 4Sum
题目链接: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:原创 2015-01-30 21:30:47 · 759 阅读 · 0 评论 -
LeetCode --- 37. Sudoku Solver
题目链接:Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.原创 2015-02-05 23:32:54 · 795 阅读 · 0 评论 -
LeetCode --- 36. Valid Sudoku
题目链接:Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.Note:A原创 2015-02-05 23:32:17 · 735 阅读 · 0 评论 -
LeetCode --- 38. Count and Say
题目链接:Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 2原创 2015-02-05 23:33:41 · 4998 阅读 · 0 评论 -
LeetCode --- 39. Combination Sum
题目链接:Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen fro原创 2015-02-06 21:39:10 · 706 阅读 · 0 评论 -
LeetCode --- 40. Combination Sum II
题目链接:Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be use原创 2015-02-06 21:39:41 · 750 阅读 · 0 评论