摘要: 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 P L S I I GY I RAnd then read line by line: "PAHNAPLSIIGYIR"Write the code that will take a string 阅读全文
posted @ 2013-11-07 01:29 七年之后 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 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 longes... 阅读全文
posted @ 2013-11-06 18:24 七年之后 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 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 a linked list.Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8注意点:改了又改,好多测试用例没有考 阅读全文
posted @ 2013-11-06 11:55 七年之后 阅读(244) 评论(0) 推荐(0) 编辑
摘要: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2013-11-05 21:18 七年之后 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 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)).思考:既然是有序数组,自然想到折半搜索。每次比较去掉其中一个数组一半的数字。class Solution {public: int func(int *A,int m,int *B,int n,int k) { if(m>n) return func(B,n,A,m, 阅读全文
posted @ 2013-11-05 21:12 七年之后 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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 nu... 阅读全文
posted @ 2013-11-05 15:11 七年之后 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 动态规划的实质是将较大问题问题分解为较小的同类子问题。与分治法和贪心法不同的是,动态规划法利用最优子结构,自底向上从子问题的最优解逐步构造出整个问题的最优解。 设计一个动态规划算法,通常可以按一下4个步骤进行: (1)刻画最优解的结构特性;(2)递归定义最优解值;(3)自底向上计算最优解值; (4)根据计算得到的信息构造一个最优解。 一个最优化多步决策问题是否适合用动态规划方法求解有两个要素:最优子结构核重叠子问题。 虽然动态规划法也是基于分解思想的,但由于子问题往往是重叠的,为了避免重复计算,动态规划算法采用字自底向上的方式进行计算,并且保存已求解的子问题的最优解值。当这些子最优解值被重复. 阅读全文
posted @ 2013-11-01 17:07 七年之后 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 首先,为什么要学习shell呢?哈哈,当然不是shell能够怎样怎样然后100字。 最近看到一篇博文《开阔自己的视野,勇敢的接触新知识》,读完反思良久。常常感慨自己所会不多,对新知识又有畏惧心理,导致自己停滞不前。古人说,逆水行舟不进则退。既然如此,何不走出自己的舒适区,迎接新挑战!好了,闲话不多说,开始我的shell学习之旅。(ps:阅读本文需要熟悉一些linux基本命令;本文给出的都是简单shell脚本的模板,开门见山,一步到位。我觉得这是快速学习的一种非常好的方法。)1.一个简单的shell脚本a.编辑脚本在创建shell脚本文件时,必须在文件的第一行指定要使用的shell,其格式为#. 阅读全文
posted @ 2013-10-31 10:46 七年之后 阅读(400) 评论(0) 推荐(0) 编辑
摘要: 本文罗列的是我在学习linux与shell编程时所遇到的一些问题。我相信既然存在问题那么就会有需求,记录于此,希望可以快速帮助到大家。1.在vim中用“/word"查找后,vim会以棕色背景高亮显示出来。下次在打开该文件,或者新建的另外文件里出现“word”后,还是会有棕色高亮背景。怎样去掉呢?解决... 阅读全文
posted @ 2013-10-30 21:25 七年之后 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 参考:《Kernel SparseRepresention-Based Classifier》原文地址:http://www.cnblogs.com/Rosanna/p/3372153.html转载请注明出处,谢谢! 阅读全文
posted @ 2013-10-16 20:32 七年之后 阅读(2112) 评论(0) 推荐(0) 编辑