只有注册用户登录后才能阅读该文。 阅读全文
posted @ 2014-09-28 12:31 Ryan in C++ 阅读(19) 评论(0) 推荐(1)
摘要: ns2-tcp-tcp.cc 1 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 2 /* 3 * Copyright (c) 1991-1997 Regents of the U... 阅读全文
posted @ 2014-09-28 10:52 Ryan in C++ 阅读(806) 评论(0) 推荐(0)
摘要: 先上自己的代码 1 class Solution { 2 public: 3 bool wordBreak(string s, unordered_set &dict) { 4 vector dp(s.size()+1,false);//dp[i]表示从下标0开始的长度为i的... 阅读全文
posted @ 2014-09-27 21:40 Ryan in C++ 阅读(195) 评论(0) 推荐(0)
摘要: 题目, 反正就是一个string,要不自己在字典里,要不切几刀,切出来的每个词都在字典里———————————————————————————————————————————————————————-Given a stringsand a dictionary of wordsdict, dete... 阅读全文
posted @ 2014-09-27 21:31 Ryan in C++ 阅读(228) 评论(0) 推荐(0)
摘要: 一定要判断好边界条件,edge case很关键。 1 #include 2 #include 3 using namespace std; 4 5 class Solution { 6 public: 7 int maxProfit(vector &prices) { 8 ... 阅读全文
posted @ 2014-09-27 18:24 Ryan in C++ 阅读(188) 评论(0) 推荐(0)
摘要: 标准库(被包含于中)提供两个帮助生成伪随机数的函数:函数一:int rand(void);从srand (seed)中指定的seed开始,返回一个[seed, RAND_MAX(0x7fff))间的随机整数。函数二:void srand(unsigned seed);参数seed是rand()的种子... 阅读全文
posted @ 2014-09-27 14:30 Ryan in C++ 阅读(179) 评论(0) 推荐(0)
摘要: http://blog.csdn.net/v_july_v/article/details/8701148假设数组为a[],直接利用动归来求解,考虑到可能存在负数的情况,我们用Max来表示以a结尾的最大连续子串的乘积值,用Min表示以a结尾的最小的子串的乘积值,那么状态转移方程为: Max=ma... 阅读全文
posted @ 2014-09-25 11:06 Ryan in C++ 阅读(325) 评论(0) 推荐(0)
摘要: 题目链接A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message c... 阅读全文
posted @ 2014-09-24 22:55 Ryan in C++ 阅读(119) 评论(0) 推荐(0)
摘要: http://fisherlei.blogspot.com/2012/12/leetcode-maximum-subarray.htmlFind the contiguous subarray within an array (containing at least one number) whic... 阅读全文
posted @ 2014-09-23 21:43 Ryan in C++ 阅读(205) 评论(0) 推荐(0)
摘要: http://qiangmzsx.blog.51cto.com/2052549/802715算法设计与分析复习——第三章:动态规划第三章:动态规划1、分治算法和动态规划算法都是通过对问题进行分解,通过对子问题的求解然后进行解重构,从而实现对原问题的求解。请指出这两种算法在对问题进行分解时各自所遵循的... 阅读全文
posted @ 2014-09-23 19:02 Ryan in C++ 阅读(4526) 评论(0) 推荐(0)