![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
牛客网
FoGoiN
这个作者很懒,什么都没留下…
展开
-
【题记】丑数
class Solution { public: int GetUglyNumber_Solution(int index) { if(index<=0) return 0; int dp[index]; dp[0]=1; //是第一个丑数 int a=0; //权值为2 int b=0; //权值为3 int c=0; //权值为5 for(int i...原创 2021-09-21 17:18:19 · 67 阅读 · 0 评论 -
【题记】旋转数组的最小数字
思路: 首先我们观察题目要求时间复杂度为logn,又是一个半有序序列此时我们就应该联想到折半查找查找半有序序列。 int minNumberInRotateArray(int* rotateArray, int rotateArrayLen ) { // write code here int left = 0; int right = rotateArrayLen-1; int mid; while(left<ri...原创 2021-09-19 11:04:17 · 72 阅读 · 0 评论 -
牛客网 重排链表
思路: 首先既然不能改变值,那么只能尝试改变next指向,但我们这个时候要知道链表的单向性,如果尝试访问最后端点,则前面的值无法再访问,重启链表只会浪费时间。 因此想到要使用线性方式进行运算! class Solution { public: void reorderList(ListNode *head) { if(head==NULL || head->next==NULL||head->next->next==NU...原创 2021-09-19 10:35:00 · 109 阅读 · 0 评论