05 2018 档案

摘要:int binary_search(const vector& stones,int val){ int sz=stones.size(); int l=0,r=sz-1; while(l>1; if(stones[mid]>=val){ r=mid-1; }else{ l=mid+1; ... 阅读全文
posted @ 2018-05-27 19:48 shulin15 阅读(219) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.com/problems/k-inverse-pairs-array/description/ 【题意】 给定n和k,求正好有k个逆序对的长度为n的序列有多少个,0<=k<=1000, 1<=n<=1000,答案模1e9+7 【思路】 dp[i][j]表示正好有j个 阅读全文
posted @ 2018-05-20 10:07 shulin15 阅读(130) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.com/problems/race-car/description/ 1. BFS剪枝 0<=current position<=2*target。为什么2*target有点不太明白 1 class Solution { 2 public: 3 int dp[100 阅读全文
posted @ 2018-05-19 20:35 shulin15 阅读(811) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.com/problems/count-the-repetitions/description/ 找循环节 https://www.cnblogs.com/grandyang/p/6149294.html 阅读全文
posted @ 2018-05-19 19:50 shulin15 阅读(107) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.com/problems/palindrome-partitioning-ii/description/ 【题意】 给定一个字符串,求最少切割多少下,使得切割后的每个子串都是回文串 【思路】 求一个字符串的所有子串是否是回文串,O(n^2) dp从后往前推 1 ve 阅读全文
posted @ 2018-05-15 10:53 shulin15 阅读(190) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.com/problems/dungeon-game/description/ 【题意】 给定m*n的地牢,王子初始位置在左上角,公主在右下角不动,王子要去救公主,每步只能往右或往下走一格。每个格子是一个整数,负数代表生命值减掉相应分数,正数表示生命值增加相应分值,要 阅读全文
posted @ 2018-05-05 15:25 shulin15 阅读(170) 评论(0) 推荐(0) 编辑