![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Algorithm
文章平均质量分 68
wust_lh
这个作者很懒,什么都没留下…
展开
-
最长公共子序列(LCS)
这两天编程涉及到求两个字符串的最长公共子序列问题,于是便重新复习之前一直没弄懂的最长公共子序列算法,也算是弄懂了一点。算法分析:采用动态规划方法来解决问题,将最长公共子序列问题转变为较小的问题。设两个字符串分别为 A="a(0),a(1),...,a(m-1)",B="b(0),b(1),...,b(n-1)",设Z="z(0),z(1),...,z(k-2)"为它们的最长公共子序列。很容...原创 2017-03-16 19:52:30 · 376 阅读 · 0 评论 -
13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.题目描述:给定一个罗马数,将其转换成数字。保证输入的数原创 2017-05-24 15:37:07 · 250 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with原创 2017-05-10 10:57:56 · 159 阅读 · 0 评论 -
14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.问题描述:写一个函数来查找字符串数组中最长的公共前缀字符串。分析:题目给出一个的是一个字符串数组,所以要考虑以下情况:(1)当字符串数组中含有""空字符串时,则最长公共前缀为空,直接返回结果;(2)当字符串数组只原创 2017-05-09 17:03:51 · 225 阅读 · 0 评论 -
35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.原创 2017-05-17 16:38:14 · 187 阅读 · 0 评论 -
9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of convertin原创 2017-05-07 20:00:43 · 159 阅读 · 0 评论 -
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sam原创 2017-05-03 20:41:09 · 299 阅读 · 0 评论 -
7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your function s原创 2017-05-05 17:41:30 · 229 阅读 · 0 评论 -
27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.原创 2017-05-12 10:51:24 · 180 阅读 · 0 评论 -
20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va原创 2017-05-11 20:32:07 · 233 阅读 · 0 评论 -
快速幂应用
快速幂就是快速算底数的n次幂。其时间复杂度为 O(log₂N), 与朴素的O(N)相比效率有了极大的提高。假设我们要求a^b,按照朴素算法就是把a连乘b次,这样一来时间复杂度是O(b),即是O(n)级别,快速幂能做到O(logn)。它的原理如下:假设我们要求a^b,那么其实b是可以拆成二进制的,该二进制数第i位的权为2^(i-1),例如当b==11时,a^11=a^(2^0+2^1+2^3)...原创 2017-09-29 10:28:49 · 404 阅读 · 0 评论