- 博客(18)
- 资源 (2)
- 收藏
- 关注
原创 list iterator not decrementable
刚遇到这个“list iterator not decrementable”的问题,网上多数解决方案是这样的:意思就是在#include "stdafx.h"的下一行加上#define _HAS_ITERATOR_DEBUGGING 0 这样虽然能解决部分问题,但其实出现这个错误的根源在我们的代码之中,如这位仁兄所回答的一样:意思就是,错误的根源在我们的代码中,因为C++标
2013-11-30 12:14:43 5547
原创 [LeetCode]Letter Combinations of a Phone Number
题目要求如下:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Dig
2013-11-27 22:10:35 903
原创 [LeetCode]3Sum Closest
题目要求如下:Given 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 would h
2013-11-25 12:39:43 954
原创 [LeetCode]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:Elements in
2013-11-24 11:20:37 7951
原创 [LeetCode]Longest Common Prefix
题目要求如下:Write a function to find the longest common prefix string amongst an array of strings.找出所有字符串的最长公共前缀。这道题很简单,但需要注意减少比较字符的操作次数。思路是这样的:2个字符串的最长公共前缀,其长度肯定不会超过最短的字符串的长度,设最短的字符串长度为n,那么只要比较这2个
2013-11-22 12:37:41 22442 1
原创 [LeetCode]Longest Palindromic Substring
题目要求如下:Given 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 substring.也就是传说中的求最长回文子
2013-11-22 11:30:42 2183
原创 求最长回文子串(Longest Palindromic Substring)
求解最长回文子串问题最近经常遇到,因而有了一个学习的契机。先说说回文字符串,回文字符串的意思是从左往右看和从右往左看都是一样的,即我们如果以中心为轴,这个字符串是左右对称的,如字符串"abcba","abba"。字符串"abcba"有奇数个字符,所以以中间字符'c'为轴左右对称,而字符串"abba"有偶数个字符,所以是对半开来对称的。而顾名思义,最长回文子串就是指一个字符串中最长的具有回文
2013-11-22 11:12:03 8278 1
原创 动态规划求解最长公共子序列(LCS)
看了《算法导论》中文第二版P208的动态规划求解LCS问题,觉得很赞,但总觉得算导写得有些晦涩,希望自己能写得简单易懂一些,纯当锻炼了,欢迎指导交流。首先,子序列和子串是不一样的。子串是连续的,而子序列中的元素组成可以是不连续的,但元素的位置下标一定是递增的。以一个字串S = "abcdef"为例,字串S的一个子串是"abc",'cdef'这种连续的,而子序列可以是"abc",也可以是"af
2013-11-15 20:23:47 9162 1
原创 [POJ]1458-Common Subsequence
题目要求:DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exis
2013-11-15 20:19:55 732
原创 [LeetCode]Container With Most Water
题目要求:Given 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 linei is at (i, ai) and (i
2013-11-14 21:27:01 854
原创 [LeetCode]Palindrome Number
题目要求:Determine 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 integer to strin
2013-11-13 21:55:16 894
原创 [LeetCode]String to Integer (atoi)
题目要求:mplement 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 what are the possible inpu
2013-11-13 21:45:36 5745 2
原创 [LeetCode]Reverse Integer
题目要求:Reverse 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. Bonus points for
2013-11-13 21:34:43 13261 10
原创 [LeetCode]Median of Two Sorted Arrays
题目要求:There 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)).如果使用像归并排序那样的归并方式,从头遍历A和B,比较A
2013-11-09 12:10:28 1150
原创 [LeetCode]ZigZag Conversion
题目要求:The 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)P A H NA
2013-11-04 11:46:29 19054 2
原创 [LeetCode]Longest Substring Without Repeating Characters
题目要求:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is
2013-11-03 11:15:31 955
原创 [LeetCode]Add Two Numbers
题目要求:You 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 and return it as
2013-11-01 22:23:21 17669 3
原创 [LeetCode]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 the two numbers such that they add up to the target,
2013-11-01 20:48:37 2291 4
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人