- 博客(11)
- 收藏
- 关注
原创 字符串的移位包含问题
题目描述:给定两个字符串s1和s2,要求判断s2是否能够被s1做循环移位(rotate)得到字符串的包含。例如 s1 = AABCD和s2 = CDAA,返回true;给定s1 = ABCD 和 s2 = ACBD,返回false。循环移位: 即对于一个长度为N的字符串数组,把下标为0的字符放到下标为1的字符的位置,把下标为1的字符放到下标为2的字符的位置,……把下标为N-2的字符放到下标
2018-01-24 22:42:14 1356
原创 [LeetCode] Algorithms-45. 230. Kth Smallest Element in a BST
描述:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the
2018-01-13 20:02:03 231
原创 [LeetCode] Algorithms-45. 123. Best Time to Buy and Sell Stock III
描述:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may
2018-01-13 19:16:13 177
原创 [LeetCode] Algorithms-122. Best Time to Buy and Sell Stock II
描述:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy
2018-01-12 00:05:47 172
原创 [LeetCode] Algorithms-121. Best Time to Buy and Sell Stock
描述:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stoc
2018-01-11 23:46:03 134
原创 [LeetCode] Algorithms-63. Unique Paths II
描述:Follow up for “Unique Paths”:Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the g
2018-01-11 18:01:10 193
原创 [LeetCode] Algorithms-62. Unique Paths
描述:A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach t
2018-01-11 14:18:21 209
原创 [LeetCode] Algorithms-45. Jump Game II
描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal i
2018-01-11 12:55:57 177
原创 [LeetCode] Algorithms-55. Jump Game
描述:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine
2018-01-11 02:26:00 176
原创 算法设计与分析期中练习题整理 2017
1000. 分组Description对于一个整数数列A[0], A[1], …, A[N-1]进行分组,要求每组1到2个数,并且同组之和不能大于w. 求最少可以分成多少组.1 例1:当A = {2, 5, 4, 3}, w = 5, minPartition(A, w)返回3. 将2和3放一组,4和5各自单独作为一组,共3组.例2:当A = {2, 5, 4, 3}, w
2018-01-06 01:17:19 2057
原创 算法概论(注释版)习题8.3
题目:吝啬SAT问题是这样的:给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。证明吝啬SAT是NP-完全问题。补充:什么是SAT问题? SAT问题也称为合取范式的可满足问题,一个合取范式形如: A1∧A2∧…∧An A1∧A2∧…∧An 其中子句 Ai(1≤i≤n)Ai(1≤i≤n)形如:a1∨a2∨…∨aka1
2018-01-05 22:38:26 388
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人