![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法刷题题解
Eric_LH
把握生命里的每一分钟
展开
-
刷算法题的感想
为了找到薪资更高的工作,决定每天多刷算法题,就像初高中每天刷数学题和试卷一样。 对于我这样的新人,刷算法题对于我个人来讲作用更大。原创 2018-08-20 16:04:07 · 4367 阅读 · 0 评论 -
漫谈算法 动态规划 Dynamic Programming
Dynamic Programming一直以来是自己比较弱的一部分,希望可以在这一块有所提升。动态规划,Dynamic Programming。这里的programming没有翻译成编程,是因为,这里的programming的意思是指一个tabular method。其实这也暗示了DP的本质,用一个table保存子问题的中间结果。(后面会有例子具体介绍)和分治算法比较类似,但不同的是分治算法把...转载 2018-10-24 16:18:03 · 318 阅读 · 0 评论 -
poj 1003
poj 1003, 已accept#include <stdio.h> int main() { float res[300] = {0,0.5},c; int i,num = 0; for (i = 2;i< 300;i++) res[i] = res[i-1] + 1.0/(i+1); while(scanf("%f"原创 2017-08-20 12:28:41 · 290 阅读 · 0 评论 -
poj 1001
已accept, poj 1001#include <iostream>using namespace std;// 计算 多 乘以 一 的情况,例如,1234 * 4// many: 多位数// one: 单位数// offset: 乘10偏移// return: 返回计算结果char * MMO(char * many, char one, int offset)原创 2017-08-20 12:26:36 · 328 阅读 · 0 评论 -
poj 1002
poj 1002, 已accept#include <stdio.h> #include <string.h> #include <stdlib.h> #define UNCODE(a) (a>='A'?((a>'Q'?(a-'A'-1):(a-'A'))/3+2):a-'0') //#define DEBUG int uncode(char* s) { int i原创 2017-08-20 12:27:54 · 299 阅读 · 0 评论 -
poj 1004
poj 1004,已 accept//Memory Time //256K 0MS #include<iostream> #include<iomanip> using namespace std; int main(void) { double sum=0.0; for(int i=1;i<=12;i++) { d原创 2017-08-20 12:29:17 · 271 阅读 · 0 评论 -
poj 1005
poj 1005 已accept#include<stdio.h> #include<math.h> int main() { int i,n; float pi,x,y,years; scanf("%d", &n); pi = acos(-1); for(i=1; i<=n; i++) { scan原创 2017-08-20 12:30:47 · 287 阅读 · 0 评论 -
那些年,超过的时 leetcode 167. Two Sum II - Input array is sorted
主要题意: Input: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2 找到求和对应的索引。最开始暴力求解:class Solution: def twoSum(self, numbers, target): """ :type numbers: List[int]...原创 2018-04-09 21:18:16 · 145 阅读 · 0 评论 -
那些年,超过的时 leetcode 347. Top K Frequent Elements
class Solution(object): def topKFrequent(self, nums, k): &quot;&quot;&quot; :type nums: List[int] :type k: int :rtype: List[int] &quot;&quot;&quot;原创 2018-04-09 21:54:06 · 153 阅读 · 0 评论 -
那些年,超过的时 442. Find All Duplicates in an Array
class Solution(object): def findDuplicates(self, nums): &quot;&quot;&quot; :type nums: List[int] :rtype: List[int] &quot;&quot;&quot; for each in set(nums):原创 2018-04-09 21:58:56 · 217 阅读 · 0 评论 -
263. Ugly Number
AC之前的,超时class Solution(object): def isUgly(self, num): """ :type num: int :rtype: bool """ while num%2==0: num=num/2 while num原创 2018-04-12 22:51:16 · 180 阅读 · 0 评论 -
697. Degree of an Array
class Solution(object): def findShortestSubArray(self, nums): """ :type nums: List[int] :rtype: int """ max_count=0 max_count_num=[] f原创 2018-04-12 23:53:56 · 177 阅读 · 0 评论 -
最长公共字串 Longest common subsequence problem
例 最长公共字串 Longest common subsequence problem问题描述:这个,很。。。显而易见吧,不知道的,。。。看这里 http://en.wikipedia.org/wiki/Longest_common_subsequence_problem当然这里,我们也是要先找递归的。假设我的两个sequence,一个是X,长度为n;另一个是Y,长度为m。现在假设我有两个p...原创 2018-10-24 16:33:56 · 409 阅读 · 0 评论