自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

原创 LeetCode 201次周赛第4题 1547. Minimum Cost to Cut a Stick

LeetCode 201次周赛第4题1547. Minimum Cost to Cut a Stick题目描述就不贴了,原题中有图片借鉴大神的方法思路代码dp填表注意事项题目描述就不贴了,原题中有图片上周比赛完没有及时写这道题,现在把坑填上。这个题的关键点在于:如果从某个位置切开了,那左右两边的就部分就一刀两断了,这样就把一个问题拆成了两个独立的子问题,非常好的动态规划样例。借鉴大神的方法思路把0和n作为两个端点加入到数组中对数组进行排序。加入了端点的数组就不只是切割点数组了,还可以作为分

2020-08-17 10:56:02 212

原创 LeetCode 202次周赛 1553. Minimum Number of Days to Eat N Oranges

1553. Minimum Number of Days to Eat N Oranges题目描述思路分析弱智动态规划可行的动态规划题目描述There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows:Eat one orange.I f the number of remaining oranges (n) is divisible by 2 then yo

2020-08-17 10:20:36 248

原创 LeetCode 1541. Minimum Insertions to Balance a Parentheses String

LeetCode 1541. Minimum Insertions to Balance a Parentheses String题目描述代码题目描述Given a parentheses string s containing only the characters ‘(’ and ‘)’. A parentheses string is balanced if:Any left parenthesis ‘(’ must have a corresponding two consecutive ri

2020-08-13 02:19:51 220

原创 LeetCode 456. 132 Pattern

132 Pattern题目思路分析用set来求解c++里面用set的lower_bound和upper_bound小心踩坑用stack求解stack求解代码题目Given a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a lis

2020-08-12 14:40:08 109

原创 LeetCode 第201次周赛 1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Leetcode 1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target题目描述思路周赛代码优化代码复杂度分析题目描述Given an array nums and an integer target.Return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarr

2020-08-10 15:51:29 275

原创 LeetCode 第201次周赛 1544. Make The String Great

LeetCode 1545. Find Kth Bit in Nth Binary String题目描述思路代码复杂度分析题目描述Given a string s of lower and upper case English letters.A good string is a string which doesn’t have two adjacent characters s[i] and s[i + 1] where:0 <= i <= s.length - 2s[i] is

2020-08-10 04:45:04 159

原创 LeetCode 第201次周赛 1545 Find Kth Bit in Nth Binary String

LeetCode 1545. Find Kth Bit in Nth Binary String题目描述思路这里简单证明一下长度是指数增长的利用构造对称性代码对称位置的计算问题代码最后一步的异或操作复杂度分析题目描述Given two positive integers n and k, the binary string SnS_nSn​ is formed as follows:S1="0"S_1 = "0"S1​="0"Si=Si−1+"1"+reverse(invert(Si−1))S_i

2020-08-10 04:27:51 116

原创 快速幂

快速幂模板题目1:ab%pa^b\%pab%p题目2:a∗b%pa*b\%pa∗b%p题目1:ab%pa^b\%pab%p输入3个数字a, b, p 求ab%p数据范围很大,最大到1018这个题目核心的就是用到了递推来防止溢出数字b可以表示成b=∑k=0k=ndk∗2kb = \sum_{k = 0}^{k=n}d_k*2^kb=∑k=0k=n​dk​∗2k,其中dkd_kdk​是二进制表示中第k位的值,dkd_kdk​只有两个取值,0或者1。那么ab=a∑k=0k=ndk∗2k=∏k=0k=na

2020-07-27 12:54:00 50

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除