自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(193)
  • 收藏
  • 关注

原创 LeetCode - 二分查找

2022-11-27 15:04:37 213 1

原创 LeetCode - 1094. 拼车

2022-11-07 21:10:56 157 1

原创 LeetCode - 1109. 航班预订统计

2022-11-07 20:46:51 149

原创 LeetCode-108将有序数组转换为二叉搜索树

class Solution { public TreeNode dfs(int[] nums ,int begin,int end) { if(begin>=0 && begin<= nums.length-1 && end>=0 && end<= nums.length-1 && begin <= end){ int mid = (end - begin.

2022-10-04 18:57:58 127

原创 LeetCode - 648 单词替换(字典树) *

2022-07-07 20:59:39 98

原创 LeetCode - 152 乘积最大子数组

2022-07-04 10:03:35 100

原创 LeetCode - 673. 最长递增子序列的个数

2022-07-02 22:18:49 94

原创 Leetcode 300 最长递增子序列

int lengthOfLIS(int* nums, int numsSize){ int count[10000]={0}; int i=0,j=0; count[0]=1; int max=0; int c=0; for(i=1;i<numsSize;i++){ count[i]=1; for(j=0;j<i;j++){ if(nums[j]<nums[i]){ c=1+cou.

2022-07-01 11:17:48 76

原创 LeetCode - 5 最长回文子串

2022-06-25 14:10:32 104

原创 LeetCode - 508. 出现次数最多的子树元素和 (二叉树的遍历)

2022-06-19 10:03:00 57

原创 LeetCode - 919. 完全二叉树插入器 (数组)

2022-06-04 20:24:53 77

原创 使用密钥对的形式连接阿里云服务器

2022-06-03 19:54:09 338

原创 LeetCode - 900. RLE 迭代器

2022-06-03 15:52:25 92

原创 LeetCode - 1172 餐盘栈 (设计 - List + 小顶堆 + 栈))

List + 小顶堆 + 栈(双端队列实现的栈)import java.util.*;class DinnerPlates { //list 栈 双端队列 //存放所有未满栈的下标的队列 private PriorityQueue<Integer> deque; //按顺序存放所有栈 private List<Deque<Integer>> list; //栈容量 private int cap...

2022-05-31 12:54:34 559

原创 LeetCode - 715. Range 模块(TreeSet) *****

TreeSetclass RangeModule { class Pair{ int left; int right; public Pair(int left,int right){ this.left = left; this.right = right; } } class PairComparator implements Comparator&l..

2022-05-30 21:11:12 133

原创 Anaconda安装包 报错packagesNotFoundError: The following packages are not available from current channels:

报错去网址 https://anaconda.org选择想要安装的版本点进去在Anaconda上 输入命令安装成功

2022-05-30 15:19:42 551

原创 LeetCode 面试题 17.20. 连续中值(大顶堆+小顶堆)

class MedianFinder { /** initialize your data structure here. */ private PriorityQueue<Integer> minHeap;//小顶堆 private PriorityQueue<Integer> maxHeap;//大顶堆 public MedianFinder() { minHeap = new PriorityQueue<Integer..

2022-05-29 17:29:50 98

原创 pycharm 无法引入自定义包

2022-05-29 11:25:29 216

原创 LeetCode - 895 最大频率栈(设计- 哈希表+优先队列 哈希表 + 栈) *

哈希表+优先队列class FreqStack { class Node{ //值的大小 int val; //值出现的频率 int freq; //值出现的时间 时间越大越靠近栈顶 int t; public Node(int val,int freq,int t){ this.val = val; this.freq = freq..

2022-05-28 21:00:45 103

原创 LeetCode - 933 最近的请求次数

双端队列class RecentCounter { private Deque<Integer> deque; public RecentCounter() { deque = new LinkedList<>(); } public int ping(int t) { deque.offerLast(t); while(deque.size()!= 0 && t - 3..

2022-05-28 17:28:07 45

原创 LeetCode - 706 设计哈希映射(设计) *

超大数组class MyHashMap { private int[] map ; public MyHashMap() { map = new int[1000001]; Arrays.fill(map,-1); } public void put(int key, int value) { map[key] = value; } public int get(int key) { ..

2022-05-28 16:37:53 66

原创 LeetCode - 703 数据流中的第 K 大元素(设计 - 优先队列)

优先队列class KthLargest { private PriorityQueue<Integer> queue; private int k; public KthLargest(int k, int[] nums) { queue = new PriorityQueue<Integer>(); this.k = k; for(int num : nums){ if(que..

2022-05-28 11:30:46 42

原创 LeetCode - 707 设计链表 (设计)

单链表注意 第一次添加节点 或者 addAtIndex(添加的节点在末尾)deleteAtIndex(删除了末尾的节点) 都有可能造成尾指针的变动 要进行判断并且更新尾指针class MyLinkedList { class Node{ int val;//节点的值 Node next;//节点的next指针 public Node(int val){ this.val = val; } }..

2022-05-28 11:12:57 55

原创 LeetCode - 677 键值映射(设计)*

前缀树+哈希表class MapSum { class TrieNode{ int val = 0; TrieNode[] child = new TrieNode[26]; } private TrieNode root; private Map<String,Integer> map; public MapSum() { root = new TrieNode(); map ..

2022-05-28 09:46:51 52

原创 LeetCode - 641 设计循环双端队列(设计)*

class MyCircularDeque { //底层数组结构 private int[] deque; //头指针 private int head; //尾指针 private int tail; //队列中实际中存放的数的个数 private int size; //队列容量 private int capacity; public MyCircularDeque(int k) { dequ...

2022-05-27 17:37:14 55

原创 LeetCode - 622 设计循环队列 (设计)

数组来实现队列class MyCircularQueue { private int[] queue;//队列数组 private int size;//队列中实际存放了多少元素 private int head;//头指针 private int tail;//尾指针 private int capacity;//队列固定大小 public MyCircularQueue(int k) { //队列固定大小为k thi..

2022-05-27 09:34:25 66

原创 LeetCode - 380 O(1) 时间插入、删除和获取随机元素 (设计 哈希表+数组)

哈希表+listclass RandomizedSet { //将值放入list中 为了可以随机取数 private List<Integer> list; //map的key是值 map的val是 值在list中的位置 //为了方便在o(1)时间内 插入删除值 private Map<Integer,Integer> map; public RandomizedSet() { list = new Array..

2022-05-25 19:48:16 75

原创 LeetCode - 303 区域和检索 - 数组不可变 (设计 前缀和数组)

class NumArray { private int[] preSum; public NumArray(int[] nums) { int n = nums.length; preSum = new int[n+1]; for(int i = 0; i < n;i++) preSum[i+1] = preSum[i] + nums[i]; } public int sumRange(int...

2022-05-25 19:04:36 52

原创 LeetCode - 232 用栈实现队列 (设计 双栈实现队列)

用两个栈实现队列class MyQueue { //使用两个栈实现队列 //主栈 private Deque<Integer> deque1; //辅助栈 private Deque<Integer> deque2; public MyQueue() { deque1 = new LinkedList<>(); deque2 = new LinkedList<>();..

2022-05-25 09:37:31 74

原创 LeetCode - 225 用队列实现栈

使用两个队列class MyStack { //使用两个队列实现栈 //主队列 private Deque<Integer> deque1; //辅助队列 private Deque<Integer> deque2; public MyStack() { deque1 = new LinkedList<>(); deque2 = new LinkedList<>();..

2022-05-25 09:34:08 53

原创 LeetCode - 379 电话目录管理系统(设计)

双端队列class PhoneDirectory { private Deque<Integer> deque; public PhoneDirectory(int maxNumbers) { deque = new LinkedList<>(); for(int i = 0; i < maxNumbers;i++) deque.offerLast(i); } publ...

2022-05-24 19:23:19 113

原创 LeetCode - 362 敲击计数器(设计)

双端队列class HitCounter { private Deque<Integer> deque; public HitCounter() { deque = new LinkedList<>(); } public void hit(int timestamp) { deque.offerLast(timestamp); } public int getHits(i..

2022-05-24 19:13:24 127

原创 LeetCode - 359 日志速率限制器 (设计)

哈希表class Logger { //printMap记录了字符串最后被打印的时间 private Map<String,Integer> printMap; public Logger() { printMap = new HashMap<>(); } public boolean shouldPrintMessage(int timestamp, String message) { if(..

2022-05-24 16:54:22 158

原创 LeetCode - 348 设计井字棋 (设计)

class TicTacToe { private int[][] rows; private int[][] cols; private int[][] diags; private int n; public TicTacToe(int n) { //rows记录每个用户每行有多少棋子 rows = new int[3][n]; //cols记录每个用户每列有多少棋子 cols = new i...

2022-05-24 11:04:21 126

原创 LeetCode - 346. 数据流中的移动平均值(设计)

class MovingAverage { private Deque<Integer> deque; private int size; int total; public MovingAverage(int size) { this.deque = new LinkedList<>(); this.size = size; total = 0; } public d..

2022-05-24 10:08:15 69

原创 LeetCode - 288 单词的唯一缩写(设计)

class ValidWordAbbr { //存放单词缩写 对应的单词 Map<String, List<String>> map = new HashMap<>(); public ValidWordAbbr(String[] dictionary) { for(String word : dictionary){ String abbreviation = calabbreviation(wo...

2022-05-24 09:40:07 76

原创 LeetCode - 281 锯齿迭代器 (设计)

双指针import java.util.NoSuchElementException;public class ZigzagIterator { private List<Integer> pv1; private List<Integer> pv2; private int pos1 ; private int pos2 ; private int num ; public ZigzagIterator(List<I...

2022-05-24 08:37:48 171

原创 LeetCode - 251展开二维向量(设计 迭代器 双指针)*

class Vector2D { List<Integer> list = new ArrayList<>();//将二维向量存放到一维数组中 int pos = 0; public Vector2D(int[][] vec) { for(int[] v: vec){ for(int n : v){ list.add(n); } } }...

2022-05-23 09:53:29 166

原创 LeetCode - 243 最短单词距离

class Solution { public int shortestDistance(String[] wordsDict, String word1, String word2) { int index1 = -1;//word1最后出现的位置 int index2 = -1;//word2最后出现的位置 int minDistance = Integer.MAX_VALUE;//最短距离 for(i...

2022-05-22 20:24:53 129

原创 LeetCode — 632. 最小区间 (滑动窗口 和76套路一样)

class Solution { public int[] smallestRange(List<List<Integer>> nums) { int k = nums.size();//共有k个整数列表 int n = 0;//共有n个数 for(int i = 0; i < k;i++){ n += nums.get(i).size(); } int[][] nums_ar.

2022-05-18 18:35:24 52

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除