11 2020 档案
摘要:class Solution { public ListNode swapPairs(ListNode head) { ListNode dummy = new ListNode(-1); ListNode p = dummy; dummy.next = head; while(p != null
阅读全文
摘要:思路 使用队列将每个链表元素放入,每次获取最小的元素加入到链表中 实现代码 class Solution { public ListNode mergeKLists(ListNode[] lists) { Queue<ListNode> heap = new PriorityQueue<>(new
阅读全文
摘要:总线锁机制 某个cpu要读取一个数据的时候,就会对总线加锁,只有当这个cpu释放锁之后其他CPU才可以获取数据 MESI协议 MESI,当我们修改本地内存的数据时,就会强制刷新到主内存,然后发布一个消息,其他CPU通过总线嗅探到修改的消息,就会将本地的数据标记为过期,然后下一次就会重新从内存中获取数
阅读全文
摘要:class Solution { public: bool isPalindrome(int x) { if(x < 0) return false; if(x == 0) return true; vector<int>nums; while(x) nums.push_back(x % 10),
阅读全文
摘要:class Solution { public: int myAtoi(string s) { if(s.empty()) return 0; // 去掉空格 int k = 0; while(s[k] == ' ') k++; bool flag = false; if(s[k] == '-')
阅读全文
摘要:题目思路 翻转一个整数,主要注意溢出的判断 实现代码 class Solution { public: int reverse(int x) { if(!x) return x; int res = 0; while(x) { if(x > 0 && res > (INT_MAX - x % 10)
阅读全文