The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following seque ...
分类:
其他好文 时间:
2020-06-21 10:13:55
阅读次数:
48
一、技术总结 本题为哈希映射的相关题目 因为一般的哈希表都是使用素数tsize进行作为最大空间,所需需要先编写一个素数判断函数,关键点是从i = 2开始遍历,只需要遍历到i * ii ? x即可; 哈希表本质是用最大的存储空间tsize取余,进行存储,但是会可能出现相同的余数,那么会发生冲突,这时就 ...
分类:
其他好文 时间:
2020-06-20 22:05:08
阅读次数:
56
postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换) 整个流程分为以下几部分: postgresql-12 安装 postgresql-12 流复制配置以及验证 pgpoll-ii-4.1 安装 pgpool-ii-4.1 主备机器自动切换配置 pgpoll-i ...
分类:
数据库 时间:
2020-06-19 14:08:50
阅读次数:
61
靠 class Solution { public int maxProfit(int[] prices) { int profit=0; for(int i=1;i<prices.length;i++){ int tmp=prices[i]-prices[i-1]; if(tmp>0) profi ...
分类:
其他好文 时间:
2020-06-18 19:30:19
阅读次数:
40
题目描述 编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target。该矩阵具有以下特性: 每行的元素从左到右升序排列。 每列的元素从上到下升序排列。 示例: 现有矩阵 matrix 如下: [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], ...
分类:
编程语言 时间:
2020-06-18 01:12:50
阅读次数:
62
80. 删除排序数组中的重复项 II class Solution { public: int removeDuplicates(vector<int>& nums) { if(nums.size()==0) return 0; if(nums.size()==1) return 1; int an ...
分类:
编程语言 时间:
2020-06-17 20:26:28
阅读次数:
58
给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 null 经典快慢指针,首先用快慢指针s,f从head开始扫描,设两个指针在一段时间t后相遇 此时慢指针走了t步,设t=a+b,其中a是环外的,b是环内部分 此时快指针走了2t步,同时快指针一定在环上绕了k圈,设环长度为c,有等式2 ...
分类:
其他好文 时间:
2020-06-17 01:15:08
阅读次数:
61
暴力法计算所有可能的交易组合相对应的利润,并找出它们其中的最大利润。Python3class Solution: def maxProfit(self, prices: List[int]) -> int: return self.calculate(prices, 0) def calculate... ...
分类:
其他好文 时间:
2020-06-16 23:27:59
阅读次数:
60
迭代对象的切片 itertools.islice() 和排列组合permutations() ...
分类:
其他好文 时间:
2020-06-16 01:08:23
阅读次数:
45
双指针 思路: 创建一个空的头结点dummy,头节点的下一节点是head。用cur指向当前要处理去重的节点,pre指向上一个完成去重的节点。初始状态pre = dummy,cur = pre.next。开始对cur进行处理,如果cur.next.val == cur.val,while遍历更新cur ...
分类:
编程语言 时间:
2020-06-15 12:15:09
阅读次数:
58