avatar
Articles
44
Tags
20
Categories
3
首页
时间轴
标签
分类
清单
  • 音乐
  • 照片
  • 电影
argcxiang's blog
首页
时间轴
标签
分类
清单
  • 音乐
  • 照片
  • 电影

argcxiang's blog

HOT100-3-回文链表
Created2025-01-23|HOT100
题目描述给你一个单链表的头节点 head ,请你判断该链表是否为回文链表。如果是,返回 true ;否则,返回 false 。 示例 1: 12输入:head = [1,2,2,1]输出:true 具体见题目描述 算法思路​ 这道题想要时间复杂度O(n)是很简单的,我写了双指针和反转数组两种方法,感觉效率都还说的过去,但是空间上不行,首先看一下反转数组: 方法一:反转数组​ 这个很容易理解,直接把链表的值读进一个数组,再把数组倒序,如果$list = reverse(list)$,那么很容易知道这是回文的,代码如下: 123456789101112131415161718192021class Solution {public: bool isPalindrome(ListNode* head) { vector<int> val_vector; ListNode *tmp = head; if (tmp == nullptr) { return...
HOT100-2-二叉树最近公共祖先
Created2025-01-22|HOT100
题目描述给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为:“对于有根树 T 的两个节点 p、q,最近公共祖先表示为一个节点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。” 示例 1: 123输入:root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1输出:3解释:节点 5 和节点 1 的最近公共祖先是节点 3 。 具体见题目链接。 算法思路​ ...
HOT100-1-相交链表
Created2025-01-22|HOT100
题目描述给你两个单链表的头节点 headA 和 headB ,请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点,返回 null 。 图示两个链表在节点 c1 开始相交 : 如图所示,则输出C1;具体见题目链接:题目链接 题目思路这道题目我是不会的……我只能想到暴力破解,就是通过两层循环进行遍历,找到最开始的地址相同的节点,伪代码差不多是这样:: 1234567891011tmpA = headA;while(tmpA != NULL) { tmpB = headB; while (tmpB != NULL) { if (tmpA != tmpB) { return tmpA; } tmpB = tmpB->next; }} return NULL; ​ ...
argcxiang's first blog
Created2025-01-21|selfintroduce
Hello, there is argcxiang, I am testing my blog on GitHub! I come from Wuhan University, majoring in Information Security, and I am interesting with some technology skills. The reason why I created this Blog is to record some experience in coding exercise, which is for next year’s summer camp, I hope all we can enter to our dream school. Thanks!
1…45
avatar
argcxiang
I am a student, majoring in information security.
Articles
44
Tags
20
Categories
3
Follow Me
Announcement
祝你今天开心!
Recent Posts
FirstKMP2025-07-14
IVW150-4-轮转数组2025-05-22
ChatBox+siliconFlow,你的AI助手!2025-05-21
IVW150-3-删除有序数组中的重复项2025-05-20
IVW150-2-移除元素2025-05-17
Categories
  • HOT10035
  • IVW1504
  • selfintroduce1
Tags
回溯 拓扑 递减栈 快慢指针 快速选择 KMP 动态规划 双指针 反转链表 桶排序 二分查找 链表 栈 分治 贪心 前缀和 哈希表 BFS DFS 循环链表
Archives
  • July 2025 1
  • May 2025 10
  • April 2025 4
  • March 2025 9
  • February 2025 9
  • January 2025 11
Website Info
Article Count :
44
Unique Visitors :
Page Views :
Last Update :
©2019 - 2025 By argcxiang
Framework Hexo|Theme Butterfly