上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: ##068. 查找插入位置 class Solution { public: int searchInsert(vector<int>& nums, int target) { int l=0,r=nums.size(); nums.push_back(1000000);//一定有数比target大 阅读全文
posted @ 2022-03-25 18:43 liv_vil 阅读(23) 评论(0) 推荐(0)
摘要: ##059. 数据流的第 K 大数值 class KthLargest { public: priority_queue<int,vector<int>,greater<int>>heap;//小根堆 维护第1大到第k大的数 top就是第k大的数 int k;//太妙了 /* 第n大 n-1 n-2 阅读全文
posted @ 2022-03-25 15:48 liv_vil 阅读(27) 评论(0) 推荐(0)
摘要: ##086. 分割回文子字符串 用substr枚举 因为是连续的 不是放与不放的问题 class Solution { public: vector<vector<string>>ans; vector<string>path; bool check() { for(string x:path) { 阅读全文
posted @ 2022-03-23 10:17 liv_vil 阅读(27) 评论(0) 推荐(0)
摘要: #我为什么要把代码粘在这里 断更很久了,基于一个错误的观念:我想看题,我到leetcode官网看不就行了吗? 但是若干年后我可能还会到我的博客园看看呀,我有可能上刷题网站吗?而且心得不好写到注释上。 记博客是长久的事,不能贪一时的方便。 这两周我并不是没有记博客,大致看完了图解系统 看了图解网络的t 阅读全文
posted @ 2022-03-09 17:57 liv_vil 阅读(35) 评论(0) 推荐(0)
摘要: ##041. 滑动窗口的平均值 Queue queue = new LinkedList(); 循环队列实现 class MovingAverage { int hh=0,tt=0; double sum=0; int []q; /** Initialize your data structure 阅读全文
posted @ 2022-03-06 23:07 liv_vil 阅读(33) 评论(0) 推荐(0)
摘要: ##036. 后缀表达式 class Solution { Stack<Integer>nums=new Stack<Integer>(); public int evalRPN(String[] tokens) { for(String x: tokens) { char k=x.charAt(0 阅读全文
posted @ 2022-03-04 22:09 liv_vil 阅读(22) 评论(0) 推荐(0)
摘要: ##030. 插入、删除和随机访问都是 O(1) 的容器 hash存数组下标 删除时 思路清奇地使用swap交换要删除的值x与nums数组尾巴y 使得能O(1)pop_back unordered_map<int,int>m; vector<int>nums; /** Initialize your 阅读全文
posted @ 2022-03-03 22:39 liv_vil 阅读(29) 评论(0) 推荐(0)
摘要: ListNode“变量”是引用 是指向该对象的遥控器 不真的是该对象 ##021. 删除链表的倒数第 n 个结点 class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { int m=0; ListNode d 阅读全文
posted @ 2022-02-28 15:06 liv_vil 阅读(28) 评论(0) 推荐(0)
摘要: ##014. 字符串中的变位词 class Solution { Map<Character,Integer> m1 =new HashMap<>(); Map<Character,Integer> m2 =new HashMap<>(); public boolean check(char c) 阅读全文
posted @ 2022-02-26 10:14 liv_vil 阅读(38) 评论(0) 推荐(0)
摘要: int是java提供的8种原始数据类型之一,Java为每个原始类型提供了封装类,Integer是java为int提供的封装类。 Integer用equals ##007. 数组中和为 0 的三个数 class Solution { public List<List<Integer>> threeSu 阅读全文
posted @ 2022-02-23 11:54 liv_vil 阅读(39) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 9 下一页