11 2021 档案
[Leetcode 787]中转K站内最便宜机票
摘要:题目 n个城市,想求从src到dist的最廉价机票 有中转站数K的限制,即如果k=5,中转10次机票1000,中转5次机票2000,最后返回2000 There are n cities connected by some number of flights. You are given an ar 阅读全文
posted @ 2021-11-30 07:23 alau 阅读(75) 评论(0) 推荐(0)
[Leetcode 1631]最少体力消耗的路径Path With Minimum Effort
摘要:题目 https://leetcode.com/problems/path-with-minimum-effort/ 每个节点的height不同,矩阵从左上走到右下,求最小体力消耗 当前点体力消耗:max(来的那个节点的effort,|来的那个节点height-当前节点height|) 总最小体力消 阅读全文
posted @ 2021-11-30 06:12 alau 阅读(76) 评论(0) 推荐(0)
[Leetcode 451]*Sort Characters By Frequency优先队列
摘要:题目 Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appe 阅读全文
posted @ 2021-11-30 02:17 alau 阅读(381) 评论(0) 推荐(0)
[Leetcode 692/347]前K个高频词Top K Frequent Words Element
摘要:题目347 https://leetcode.com/problems/top-k-frequent-elements/ 347简单些,692是其变式,多了一种排序 Given an integer array nums and an integer k, return the k most fre 阅读全文
posted @ 2021-11-30 01:41 alau 阅读(37) 评论(0) 推荐(0)
[Leetcode 703]流中第K个最大元素Kth Largest Element in a Stream优先队列239
摘要:题目 找到一串数字中的第K大元素 在原数组的基础上,每次会不断插入元素 插入的同时要返回插入后第K大的元素 https://leetcode.com/problems/kth-largest-element-in-a-stream/ Design a class to find the kth la 阅读全文
posted @ 2021-11-29 04:10 alau 阅读(62) 评论(0) 推荐(0)
[Leetcode 5] 最长回文子串Longest Palindromic Substring
摘要:问题 求最长回文子串,即左右对称 Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a va 阅读全文
posted @ 2021-11-28 06:27 alau 阅读(44) 评论(0) 推荐(0)
[Leetcode 42]雨天积水面积Trapping Rain Water
摘要:题目 下雨天的蓄水量计算 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after ra 阅读全文
posted @ 2021-11-28 04:54 alau 阅读(59) 评论(0) 推荐(0)
[Leetcode 1041]机器人围成圈 Robot Bounded In Circle
摘要:题目 机器人从(0,0)出发,初始化向北 三种指令 G当前方向+1步,L左转90度,R右转90度 问指令结束后是否成圆圈(只有可能回原点时才成圈) 返回true/false On an infinite plane, a robot initially stands at (0, 0) and fa 阅读全文
posted @ 2021-11-28 00:36 alau 阅读(265) 评论(0) 推荐(0)
[Leetcode 138]复制带随机指针的数列Copy List with Random Pointer
摘要:题目 深复制一个list* Node的结构包含next和random(随机指向节点) 区别 深复制 deep copy Node a=New Node(1) Node b=new Node(1) 复制值 浅复制 shallow copy Node a=new Node(1); Node b=a; 复 阅读全文
posted @ 2021-11-26 21:32 alau 阅读(48) 评论(0) 推荐(0)
[整理]简单的基础问题坑
摘要:遇到的一些基础坑 **注意int size=q.size(),再把size放进for循环。直接for(i;i<q.size();i++)报错 https://www.cnblogs.com/inku/p/15591457.html return tmp.next;//不能直接head,head本身可 阅读全文
posted @ 2021-11-26 05:16 alau 阅读(32) 评论(0) 推荐(0)
[Leetcode 207/210]课程计划Course Schedule I II(BFS)310
摘要:310题目类似,但是数据结构可以选的更简单 恢复内容开始 题目 先修课程和后修课,比如高数离散修完,才能修数据结构 给定numcourse门课程,int[][]的先后计划。int[i][0]为要修的当前课程,int[i][1]为学这门课之前要修的课 207/210都在问:按照int[][],所有课程 阅读全文
posted @ 2021-11-26 05:14 alau 阅读(26) 评论(0) 推荐(0)
[Leetcode 103]二叉树zigzag交叉遍历Binary Tree Zigzag Level Order Traversal
摘要:题目 二叉树zigzag遍历 层次遍历:始终左右 zigzag遍历:每层右左左右交替 Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from 阅读全文
posted @ 2021-11-23 05:34 alau 阅读(114) 评论(0) 推荐(0)
[Leetcode 124]二叉树最大权重路径和 Binary Tree Maximum Path Sum
摘要:题目 与543相似,543是求最长路径,这是最大权重求和(路径不一定最长) A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge con 阅读全文
posted @ 2021-11-23 04:45 alau 阅读(259) 评论(0) 推荐(0)
[Leetcode 543]二叉树的直径Diameter of Binary Tree
摘要:题目 二叉树的直径,即是求树中任意俩点间的最大距离(深度) Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the len 阅读全文
posted @ 2021-11-23 04:24 alau 阅读(41) 评论(0) 推荐(0)
[Leetcode 19]删除链表中倒数第N个元素Remove Nth Node From End of List
摘要:题目 删除链表head中倒数第N个元素 Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1: Input: head = [1,2,3 阅读全文
posted @ 2021-11-23 01:13 alau 阅读(37) 评论(0) 推荐(0)
[整理]leetcode位运算系列题
摘要:https://www.jianshu.com/p/3cd3f2023ac4 https://www.bilibili.com/video/BV1pr4y1c7B8 与AND & 两个1,即为1 或OR | 只要有一个1,即为1 亦或XOR ^ 相同为0,不同为1(不进位加法,0+0=0,1+0=1 阅读全文
posted @ 2021-11-23 00:49 alau 阅读(36) 评论(0) 推荐(0)
[模板]删除重复值leetcode26/27/80/283
摘要:不消耗额外空间的前提下,将数字向前移向。 https://www.bilibili.com/video/BV1Pv4y1Z76N 阅读全文
posted @ 2021-11-22 07:30 alau 阅读(41) 评论(0) 推荐(0)