LeetCode刷题笔记
LeetCode刷题笔记
数学工具构造器
这个作者很懒,什么都没留下…
展开
-
极客时间模拟面试
你的闪光点是什么单例模式可以做什么数据库连接只生成一个对象单例模式可能遇到的问题用Python语言构造一个单例模式用new方法返回一个实例对象有instance内部成员变量,如果是None,生成实例对象过程中注意什么多线程的问题二叉树的最大深度最大深度:从根节点到叶子结点的数目想法1. 递归时间复杂度 O(N)O(N)O(N) N 代表节点数想法2.广度优先...原创 2021-01-07 21:07:44 · 368 阅读 · 0 评论 -
C++语法汇总
文章目录C++ 常用头文件和宏定义CLion模板输入输出C++ 常用头文件和宏定义一了百了#include <bits/stdc++.h>大军来袭#include<cstdio>#include<cstring>#include<algorithm>#include<iostream>#include<string>#include<vector>#include<stack>#原创 2020-12-06 10:43:03 · 444 阅读 · 0 评论 -
算法题刷题笔记
双指针977. 有序数组的平方baselineclass Solution: def sortedSquares(self, A: List[int]) -> List[int]: return sorted([x**2 for x in A])双指针class Solution: def sortedSquares(self, A: List[int]) -> List[int]: N = len(A) start =原创 2020-10-16 11:18:28 · 971 阅读 · 0 评论 -
golang语法学习
1https://leetcode.com/problems/two-sum/二重循环func twoSum(nums []int, target int) []int { for i := 1; i < len(nums); i++ { for j := 0; j < i; j++ { if nums[i]+nums[j] == target { ret...原创 2019-10-15 14:49:20 · 248 阅读 · 0 评论 -
其他
其他void nextPermutation(vector<int>& nums) { int n=nums.size(); int i=n-1; while(i>=0 && nums[i+1]<=nums[i]){ // 注意,<= i--; } if(i>=0){ ...原创 2019-08-25 18:01:23 · 238 阅读 · 0 评论 -
位运算
位运算不显示使用除法和乘法实现除法https://leetcode.com/problems/divide-two-integers/二进制实现除法https://leetcode.com/problems/divide-two-integers/discuss/338701/C%2B%2B-32-bit-binary-long-division-algorithm-O(32)-O(1)...原创 2019-07-25 21:07:49 · 257 阅读 · 0 评论 -
动态规划
最小编辑距离https://zhuanlan.zhihu.com/p/80682302https://leetcode.com/problems/edit-distance/submissions/记忆化搜索class Solution { int[][] mem; String s1; String s2; int recursion(int i, ...原创 2019-09-28 17:27:21 · 292 阅读 · 0 评论 -
python与java等价语句表
PythonJavamin(1,2,3)Arrays.stream(new int[]{1,2,3}).min().getAsInt();lst=[1,2,3]List<Integer> list=Arrays.asList(1,2,3);原创 2019-09-28 16:35:17 · 294 阅读 · 0 评论 -
二分
74. Search a 2D Matrixcpp#include <bits/stdc++.h>#define FF(a, b) for(int a=0;a<b;a++)#define F(a, b) for(int a=1;a<=b;a++)#define LEN 100#define INF 1000000#define bug(x) cout&l...原创 2019-10-01 12:09:19 · 222 阅读 · 0 评论 -
链表,链状结构
文章目录61. Rotate List61. Rotate Listhttps://leetcode.com/problems/rotate-list/除了AC以外,还实现了一些链表的方法,如fromArray, toString等public class Main { public static void main(String[] args) { ListNod...原创 2019-10-02 01:11:39 · 335 阅读 · 0 评论 -
数论
1. 快速幂https://leetcode.com/problems/powx-n/class Solution {public: double myPow(double x, int n) { double base=x; double ans=1; long long an=abs((long long)n); w...原创 2019-09-09 00:59:56 · 234 阅读 · 0 评论 -
各种语言基础算法对照表
算法\语言C++JavaPythonGo二分查找findlower_boundupper_bound原创 2019-09-05 17:39:17 · 355 阅读 · 0 评论 -
深度优先搜索算法(dfs)
文章目录1. combination sum2. Combination Sum II1. combination sumhttps://leetcode.com/problems/combination-sum/Example 1:Input: candidates = [2,3,5], target = 8,A solution set is:[ [2,2,2,2], [2...原创 2019-09-03 16:13:31 · 278 阅读 · 0 评论 -
数据结构:数组、列表等
56. Merge Intervalshttps://leetcode.com/problems/merge-intervals/pythonclass Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals.sort(key=lambda x:x...原创 2019-09-30 00:02:58 · 241 阅读 · 0 评论