![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
thebs2
这个作者很懒,什么都没留下…
展开
-
Leetcode 买股票问题模板
dp[i][k][0] = max(dp[i-1][k][0], dp[i-1][k][1] + prices[i]) //max( 选择 rest , 选择 sell ) 解释:今天我没有持有股票,有两种可能: 要么是我昨天就没有持有,然后今天选择 rest,所以我今天还是没有持有; 要么是我昨天持有股票,但是今天我 s...原创 2020-03-10 14:55:05 · 153 阅读 · 1 评论 -
LeetCode #67. Add Binary
给定两个二进制字符串,返回他们的和(用二进制表示)。 输入为非空字符串且只包含数字1和0。 先将短的字符串进行补全,然后从最后面(最低位)开始逐位相加,由于是char类型所以运用(ASCII码 - '0')来表示1和0并且,注意。最高位的处理还有sum值四种可能0,1,2,3,当sum>=2 时需要进位并且当前位取值应该位sum -2,即2的时候应该取0,3的适合取1。 st...原创 2019-10-13 20:03:59 · 103 阅读 · 0 评论 -
LeetCode #19. Remove Nth Node From End of List
Given a linked list, remove then-th node from the end of list and return its head. 问题描述:删除链表倒数第n个节点。 设置新的head,统计链表长度,当删除第一个节点时需要额外处理,否则当链表长度为1时返回的head并未经过处理。 class Solution { public: ListNode * ...原创 2019-05-09 23:41:53 · 67 阅读 · 0 评论 -
LeetCode #922. Sort Array By Parity II
Given an arrayAof non-negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that wheneverA[i]is odd,iis odd; and wheneverA[i]is even,iis...原创 2019-05-09 23:51:08 · 68 阅读 · 0 评论 -
LeetCode #950. Reveal Cards In Increasing Order
In a deck of cards, every card has a unique integer. You can order the deck inany order you want. Initially, all the cards start face down (unrevealed) in one deck. Now, you do the following steps...原创 2019-05-10 00:07:32 · 171 阅读 · 0 评论