随笔分类 - 数据结构与算法
摘要:  { int[] result = new int[k]; HashMap<Integer, Integer> map = new HashMa
阅读全文
摘要:自己版: package leetcode.mySort; public class QuickSort { public static int partition(int[] array,int start,int end){ int base = array[start]; while (sta
阅读全文
摘要:自己造轮子 class LRUCache { // 题根据目要求函数 get 和 put 必须以 O(1) 的平均时间复杂度运行,所以一定需要用到HashMap。 // 同时,需要删除最久未使用,也就是说需要保留顺序,需要用到队列,并且插入删除复杂度O(1),所以需要用到链表(双向)实现的队列 //
阅读全文
摘要:转载: https://blog.csdn.net/KingGue/article/details/123335283?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%
阅读全文
摘要:https://leetcode.cn/problems/combination-sum/solution/hui-su-suan-fa-jian-zhi-python-dai-ma-java-dai-m-2/ https://www.pudn.com/news/627ded6c5981aa38ef
阅读全文
摘要:def merge(arr,tempArr,left,mid,right): # 标记左半区第一个未排序的元素 l_pos = left # 标记右半区第一个未排序的元素 r_pos = mid + 1 # 临时数组元素的下标 pos = left # 合并 while l_pos <= mid a
阅读全文
摘要:求素数 public class Main { public static void main(String[] args) { for (int i = 2; i < 1000; i++) { if (isSimple(i)){ System.out.println(i); } } } publi
阅读全文
摘要:转载参考:https://blog.csdn.net/weixin_43059934/article/details/123316433 https://zhuanlan.zhihu.com/p/438909352 牛客练习网址:https://ac.nowcoder.com/acm/contest
阅读全文
摘要:class Solution: def topKFrequent(self, words, k): v1_dict = {} for i in words: v1_dict[i] = v1_dict.get(i,0)+1 data = sorted(v1_dict.items(),key=lambd
阅读全文
摘要:转载大佬的链接 import java.util.*; public class Main { /** * 组合数和杨辉三角:第i行第j列的数都是组合数C(i, j) (i,j从0开始) C(n, 1) = n --> 对应从左向右看斜着的第二列! > 一定有解 由于杨辉三角左右对称(C(a, b)
阅读全文
摘要:参考:https://blog.csdn.net/Promise_Lv_2019/article/details/106318649
阅读全文
摘要:# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def
阅读全文
摘要:参考:https://leetcode-cn.com/u/leetcode-solution
阅读全文
摘要:递归的办法: 动态规划: 迭代: 选自:https://www.bilibili.com/video/BV1AB4y1w7eT
阅读全文
摘要:转载:https://www.cnblogs.com/cthon/p/9251909.html
阅读全文
摘要:参考:https://www.cnblogs.com/AlgrithmsRookie/p/5919164.html https://www.cnblogs.com/fivestudy/p/10217887.html #一、简单递归的实现 #include "stdafx.h" #include <s
阅读全文