上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 23 下一页
摘要: 题意简述:求两个字符串的最长公共子序列的长度思路:最经典的最长公共子序列的长度(LCS问题)。动态转移方程如下:字符串X和字符串Y,dp[i][j]表示的是X的前i个字符和Y的前j个字符的最长公共子序列长度。如果 X[i]==Y[j],那么新的LCS+1;如果X[i]!=Y[j],则分别考察dp[i... 阅读全文
posted @ 2015-08-02 14:13 尾巴草 阅读(210) 评论(0) 推荐(0) 编辑
摘要: next数组用于存储模式串中元素为j位置的最大重叠度。//KMP算法实现字符串匹配 //#include #include using namespace std; void compute_next(int* next,char const*p,int len){ int j=0; ... 阅读全文
posted @ 2015-07-20 18:27 尾巴草 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Problem:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->... 阅读全文
posted @ 2015-07-16 16:51 尾巴草 阅读(118) 评论(0) 推荐(0) 编辑
摘要: problem:Given 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. ... 阅读全文
posted @ 2015-07-16 15:55 尾巴草 阅读(116) 评论(0) 推荐(0) 编辑
摘要: problem:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2... 阅读全文
posted @ 2015-07-16 11:03 尾巴草 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Problem:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:顺时针方... 阅读全文
posted @ 2015-07-16 10:34 尾巴草 阅读(110) 评论(0) 推荐(0) 编辑
摘要: problem:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路解析:使用hashmap来存储已排好序的字符串。注意i... 阅读全文
posted @ 2015-07-14 14:53 尾巴草 阅读(161) 评论(0) 推荐(0) 编辑
摘要: Problems:Given an array of integers, every element appears three times except for one. Find that single one. Note:Your algorithm should have a linear ... 阅读全文
posted @ 2015-07-14 09:52 尾巴草 阅读(97) 评论(0) 推荐(0) 编辑
摘要: Problems:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtim... 阅读全文
posted @ 2015-07-11 19:59 尾巴草 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Problem:Write a function to find the longest common prefix string amongst an array of strings.Solution:题意要求求取字符串数组的最长公共前缀子串。从位置0开始,对每一个位置比较所有的字符串,直到遇到... 阅读全文
posted @ 2015-07-11 19:46 尾巴草 阅读(123) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 23 下一页