102. 二叉树的层序遍历 给你一个二叉树,请你返回其按层序遍历得到的节点值。(即逐层地,从左到右访问所有节点)。 解答 103. 二叉树的锯齿形层序遍历 给定一个二叉树,返回其节点值的锯齿形层序遍历。(即先从左往右,再从右往左进行下一层遍历,以此类推,层与层之间交替进行)。 解答 其他题:大数相加 Read More
posted @ 2021-04-01 16:37 洗盏更酌 Views(223) Comments(0) Diggs(0)
问题1. 下面2句内联汇编是等价的么? asm volatile("s_waitcnt lgkmcnt(%0)" :: "i"(3)); s_waitcnt lgkmcnt(3) 这两条语句是完全等价的 立即数约束的匹配性 "i"(3) 约束强制编译器将数值 3 作为立即数直接嵌入指令编码中,这与原 Read More
posted @ 2025-05-25 18:00 洗盏更酌 Views(46) Comments(0) Diggs(0)
在AMD CDNA架构中,s_waitcnt指令用于确保特定类型的指令(如内存操作或数据共享操作)完成后再继续执行后续指令。以下是vmcnt和lgkmcnt后数字的具体含义及用户汇编代码中的用法分析: 1. 计数器的定义 AMD CDNA架构通过三个计数器管理指令依赖性: vmcnt(Vector Read More
posted @ 2025-05-24 20:39 洗盏更酌 Views(161) Comments(0) Diggs(0)
题目链接 解题思路:滑动窗口 C++: class Solution { public: unordered_map <char, int> ori, cnt; bool check() { for (const auto &p: ori) { if (cnt[p.first] < p.second Read More
posted @ 2021-04-06 17:37 洗盏更酌 Views(60) Comments(0) Diggs(0)
题目链接 解题思路: C++: class Solution { public: int compareVersion(string version1, string version2) { int n1 = version1.size(), n2 = version2.size(), end = Read More
posted @ 2021-04-06 11:17 洗盏更酌 Views(44) Comments(0) Diggs(0)
题目连接 解题思路: 从左往右层序遍历一个二叉树,在某一层的节点队列中,如果某个pop出的节点为空,并且队列中仍然有非空的元素,说明这个二叉树不是完全二叉树。 C++: /** * Definition for a binary tree node. * struct TreeNode { * in Read More
posted @ 2021-04-05 00:50 洗盏更酌 Views(53) Comments(0) Diggs(0)
题目链接 解题思路:双指针 C++: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} Read More
posted @ 2021-04-03 20:38 洗盏更酌 Views(27) Comments(0) Diggs(0)
题目链接 解题思路: 使用层序遍历,输出每一层最右边的节点即可。 C++: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * T Read More
posted @ 2021-04-02 15:46 洗盏更酌 Views(78) Comments(0) Diggs(0)
题目链接 解题思路: 迭代C++: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * Read More
posted @ 2021-04-02 10:51 洗盏更酌 Views(46) Comments(0) Diggs(0)
题目链接 解题思路: 直接上代码: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * Read More
posted @ 2021-04-02 00:48 洗盏更酌 Views(92) Comments(0) Diggs(0)