![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
Aimer_N
这个作者很懒,什么都没留下…
展开
-
LeetCode 413.等差数列的划分
这题感觉其实是个找规律的题,写一下思路吧 一个单调递增的序列,在后面加上一个依旧符合该递增性质的数,数列的总长度就+n,也就是总的子序列个数为 1+2+3+4+5+6+...+(n-1)+n 这里简单地推一下这个公式,以求长度>=3为例 第一个序列为1 2 3 长度三的递增子序列个数为1 末尾+4 得到1 2 3 4及2 3 4个数为2 末尾+5 得到1 2 3 4 5,2 3 4 5,3 4 5个数为3 末尾+6 得到1 2 3 4 5 6,2 3 4 5 6,3 4 5 6,4 5 6个数...原创 2021-08-10 09:20:56 · 108 阅读 · 0 评论 -
LeetCode 2100题 面试题08.05.递归乘法
因为是第一次做感觉很有意思,题目的大意是给定两个int的整数要求递归实现乘法 具体想法就是假如输入的是72拆解成71+7*1及7+7 由此推得74拆成72+72,继续71+71+71+7*1 如果是7*3这种奇数加一次7然后继续按照偶数处理即可 class Solution { public: int multiply(int A, int B) { if(B == 0) return 0; if(B == 1) return A; ..原创 2021-07-20 19:24:50 · 151 阅读 · 0 评论 -
LeetCode第二题两数相加C
写几个我遇到的问题 runtime error: member access within misaligned address 0xbebebebebebebebe for type ‘struct ListNode’, which requires 8 byte alignment [ListNode.c] 0xbebebebebebebebe: note: pointer points here 这个是因为c你定义了指针以后,他的->next默认是没有指向任何东西的,需要付一步空就好了原创 2021-07-18 14:12:53 · 353 阅读 · 0 评论