![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
文章平均质量分 75
Black_Cater
这个作者很懒,什么都没留下…
展开
-
Procedue of building rest API using Node, Express, PostgreSQL and Docker
【代码】Procedue of building rest API using Node, Express, PostgreSQL and Docker。原创 2022-10-17 08:20:18 · 222 阅读 · 1 评论 -
Fenwick Tree学习 灵魂画手 307. Range Sum Query - Mutable 线段树
这个人说的非常非常非常清晰,强烈推荐https://www.youtube.com/watch?v=uSFzHCZ4E-8对数组进行切分, 根据二进制排出父子节点。class BIT { int[] aux; public BIT(int[] nums) { aux = new int[nums.length + 1]; System.arraycopy(nums, 0, aux, 1, nums.length); for (int i原创 2021-03-30 21:35:12 · 123 阅读 · 0 评论 -
322. Coin Change 非常经典的动态规划问题
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, retu.原创 2021-02-07 11:55:26 · 213 阅读 · 0 评论 -
42. Trapping Rain Water
给定一组数组,分别代表不同长度的柱子,求最大装水容量;https://leetcode.com/problems/trapping-rain-water/Example 1:Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: Theabove elevation map (black section) is represented by array[0,1,0,2,1,0,1,3,2,1,2,1]. In this c原创 2020-12-20 22:49:25 · 76 阅读 · 0 评论 -
LeetCode.46 & 47 全排列
PermutataionAlgs:基础回溯算法,列出每种可能性, 剪枝直接在每次递归最后撤销选择即可。public List<List<Integer>> permute(int[] nums) { List<List<Integer>> res = new ArrayList<>(); List<Integer> list = new ArrayList<>(); .原创 2020-12-07 23:50:22 · 98 阅读 · 0 评论 -
LeetCode 31. Next Permutation
题目: 给定一个数组, 找出其permutation中下一个大的permutation;解释: 按照从小到大的顺序,如果数组是12432, 那么需要返回13224, 即下一个比他大的数组。题解:1.从右往左遍历数组,一旦发现有降序相邻数组,即nums[i] > nums[i-1], 那么变化一定是在nums[i-1],使从i-1向后的数组成为原数组i-1向后数组的下一个最大permutation;2. 确定改变位置之后,需要找到下一个最大的值与i-1位置的值交换,这里注意,是要找到比nums[原创 2020-12-07 13:42:30 · 120 阅读 · 0 评论 -
LeetCode 287. Find the Duplicate Number
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.There is only one duplicate number in nums, return this duplicate number.Follow-ups:How can we prove that at least one duplicate number must ex原创 2020-12-04 13:58:11 · 114 阅读 · 0 评论 -
Algorithms Part II Maxflow 笔记
MinCut初始化是一个edge-weighted digraph, 有一个源点是s, 和目标点t;st-cut(cut)/ 割:将digraph的点分为两个不相连的集合,s在一个集合A,t在一个集合B;Capacity 从集合A到B的所有edge的容量总和;mincut : 拥有最小capacity的割问题;MaxFlowflow : 流,1. 小于等于该边容量;2. 输入流和输出流必须相等(除了s和t,在有向图中,假设s只有输出,t只有输入);##最大流问题就是找到输入目标终点的最大流原创 2020-11-30 11:28:47 · 204 阅读 · 0 评论 -
300. Longest Increasing Subsequence
Given an integer array nums, return the length of the longest strictlyincreasing subsequence.A subsequence is a sequence that can be derived from an array bydeleting some or no elements without changing the order of theremaining elements. For example,.原创 2020-11-19 11:26:30 · 84 阅读 · 0 评论 -
Princeton Algorithms. QuickSort
Algorithm打乱数组;随机挑选一个值(一般取第一个),使得它的左侧全部小于他,右侧全部大于他;(用两个指针,一个遍历找到小于它的,一个遍历找到大于它的, 如果发现未知反了,那么交换两个指针当前位置的值)将左右部分递归,得出有序数组Implementation:4. 找到索引位置private int partition(Comparable[] a, int lo, int hi) { int i = lo; int j = hi; while (true) { // 找到需原创 2020-10-15 12:28:11 · 101 阅读 · 0 评论 -
Princeton Algorithm ElementarySort
1. Selection SortAlgorithm:一个指针遍历数组,另一个指针遍历后面位置的值并找到最小值,与当前指针位置的值进行交换。时间复杂度O(N^2).public void selectionSort(int[] a) { int size = a.length; for (int i = 0; i < size; i++) { // 选择当前遍历到的点作为最小值 int min = i; // 然后遍历后面的数,找到最小值,并且替换到当前位置 for (int原创 2020-10-14 10:59:37 · 131 阅读 · 0 评论