上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 22 下一页
摘要: 问题描述: 给定两个序列 X=, Y,求X和Y长度最长的公共子序列。(子序列中的字符不要求连续) 这道题可以用动态规划解决。定义c[i, j]表示Xi和Yj的LCS的长度,可得如下公式:伪代码如下:C++实现:int longestCommonSubsequence(string x, strin... 阅读全文
posted @ 2015-08-10 10:15 Sawyer Ford 阅读(3059) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−... 阅读全文
posted @ 2015-08-09 18:35 Sawyer Ford 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 快速排序是相当重要的一种排序方法。它的特点有:1. 平均时间复杂度为O(nlogn),最坏时间复杂度为O(n^2)。2. 平均空间复杂度为O(logn),最坏空间复杂度为O(n)。3. 不稳定 快排的实现方法有多种,这里只列出常用的两种。单向扫描版:int partition(int arr[... 阅读全文
posted @ 2015-08-05 09:21 Sawyer Ford 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 题目描述: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",... 阅读全文
posted @ 2015-08-04 20:12 Sawyer Ford 阅读(193) 评论(0) 推荐(0) 编辑
摘要: traits编程技法利用了“内嵌型别”的编程技巧与编译器的template参数推导功能。 下面主要看看利用traits编程技法实现的迭代器萃取机制。 5种迭代器类型定义: std::iterator的定义 如果想和STL协同工作,自行定义的迭代器必须定义iterator_category、value 阅读全文
posted @ 2015-08-04 10:00 Sawyer Ford 阅读(228) 评论(0) 推荐(0) 编辑
摘要: STL以泛型思维为基础,提供了6大组件:容器(containers)、算法(algorithms)、迭代器(iterators)、仿函数(functors)、适配器(adapters)、分配器(allocators)。 容器: vector、list、deque、set、map等,用来存放数据。从实 阅读全文
posted @ 2015-08-04 09:22 Sawyer Ford 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 连接MySQL 查看MySQL 操作MySQL 阅读全文
posted @ 2015-07-28 17:25 Sawyer Ford 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space? 这题思路就是把单链表的前半部分或后半部分反转,然后比较。s... 阅读全文
posted @ 2015-07-25 18:35 Sawyer Ford 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipe... 阅读全文
posted @ 2015-07-24 21:04 Sawyer Ford 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 题目描述:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given s... 阅读全文
posted @ 2015-07-23 22:36 Sawyer Ford 阅读(158) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 22 下一页