刷题again
文章平均质量分 53
备战实习
Heisenberg_888
互联网工程师,努力学习中
展开
-
5. 最长回文子串
"aba" 同样是符合题意的答案。中最长的 回文子串。原创 2024-09-12 22:01:17 · 374 阅读 · 0 评论 -
64. 最小路径和
请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。因为路径 1→3→1→1→1 的总和最小。每次只能向下或者向右移动一步。给定一个包含非负整数的。原创 2024-09-09 22:15:15 · 304 阅读 · 0 评论 -
LeetCode hot100刷题记录
LeetCode刷题记录 (yuque.com)原创 2024-09-04 09:04:31 · 151 阅读 · 0 评论 -
279. 完全平方数
是一个整数,其值等于另一个整数的平方;换句话说,其值等于一个整数自乘的积。的完全平方数的最少数量。原创 2024-08-29 21:21:01 · 158 阅读 · 1 评论 -
Leetcode 118. Pascal‘s Triangle
Given a non-negative integernumRows, generate the firstnumRowsof Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:...原创 2019-02-11 12:32:59 · 223 阅读 · 0 评论 -
763. 划分字母区间
【代码】763. 划分字母区间。原创 2024-08-25 13:04:01 · 143 阅读 · 0 评论 -
295. 数据流的中位数
/ 返回 1.5 ((1 + 2) / 2)是有序整数列表中的中间值。如果列表的大小是偶数,则没有中间值,中位数是两个中间值的平均值。返回到目前为止所有元素的中位数。以内的答案将被接受。原创 2024-08-23 23:23:27 · 427 阅读 · 0 评论 -
394. 字符串解码
你可以认为输入字符串总是有效的;输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的。此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数。给定一个经过编码的字符串,返回它解码后的字符串。,表示其中方括号内部的。原创 2024-08-16 20:11:27 · 304 阅读 · 0 评论 -
208. 实现 Trie (前缀树)
是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补完和拼写检查。// 返回 False。// 返回 True。// 返回 True。// 返回 True。(发音类似 "try")或者说。原创 2024-08-02 19:41:20 · 337 阅读 · 0 评论 -
994. 腐烂的橘子
左下角的橘子(第 2 行, 第 0 列)永远不会腐烂,因为腐烂只会发生在 4 个方向上。直到单元格中没有新鲜橘子为止所必须经过的最小分钟数。因为 0 分钟时已经没有新鲜橘子了,所以答案就是 0。的新鲜橘子都会腐烂。原创 2024-07-29 22:20:50 · 436 阅读 · 0 评论 -
中缀表达式
NC137表达式求值,再写一次描述请写一个整数计算器,支持加减乘三种运算和括号。示例1输入:"1+2"返回值:3题目链接:表达式求值_牛客题霸_牛客网 (nowcoder.com)class Solution {public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * 返回表达式的值 * @param s string字符串 待计算的表达式 * @return int整.原创 2021-08-24 16:14:17 · 137 阅读 · 0 评论 -
链表中环的入口节点
链表中环的入口节点_牛客题霸_牛客网 (nowcoder.com)原创 2021-05-07 10:46:53 · 84 阅读 · 0 评论 -
kmp算法
题目描述给你一个非空模板串S,一个文本串T,问S在T中出现了多少次示例1输入"ababab","abababab"返回值2示例2输入"abab","abacabab"返回值1题目链接:https://www.nowcoder.com/practice/bb1615c381cc4237919d1aa448083bcc?tpId=117&tqId=37859&rp=1&ru=%2Fta%2Fjob-code-high&qr原创 2021-04-08 15:54:30 · 403 阅读 · 0 评论 -
通配符匹配
请实现支持'?'and'*'.的通配符模式匹配'?' 可以匹配任何单个字符。'*' 可以匹配任何字符序列(包括空序列)。返回两个字符串是否匹配函数声明为:bool isMatch(const char *s, const char *p)下面给出一些样例:isMatch("aa","a") → falseisMatch("aa","aa") → trueisMatch("aaa","aa") → falseisMatch("aa", "*") → trueisMatch("原创 2021-04-05 22:13:49 · 216 阅读 · 0 评论 -
最小编辑代价
题目描述给定两个字符串str1和str2,再给定三个整数ic,dc和rc,分别代表插入、删除和替换一个字符的代价,请输出将str1编辑成str2的最小代价。示例1输入"abc","adc",5,3,2返回值2示例2输入"abc","adc",5,3,100返回值8备注:题目链接:https://www.nowcoder.com/practice/05fed41805ae4394ab6607d0d745c8e4?tpId=188&tq原创 2021-04-04 16:17:07 · 139 阅读 · 0 评论 -
POJ1458 最长公共子序列长度
DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., ...原创 2020-05-04 12:32:32 · 365 阅读 · 0 评论 -
括号序列
题目描述给出一个仅包含字符'(',')','{','}','['和']',的字符串,判断给出的字符串是否是合法的括号序列括号必须以正确的顺序关闭,"()"和"()[]{}"都是合法的括号序列,但"(]"和"([)]"不合法。示例1输入"["返回值false示例2输入"[]"返回值true题目链接:https://www.nowcoder.com/practice/37548e94a270412c8b9fb85643c8ccc2?tpId=117&a原创 2021-04-01 11:46:52 · 202 阅读 · 0 评论 -
在有序旋转数组中找到最小值
#include<bits/stdc++.h>using namespace std;int main(){ int n; while(cin>>n) { vector<int> vc(n+1,0); for(int i=0;i<n;i++) { cin>>vc[i]; } int low=0,high=n-1,m...原创 2021-03-31 15:58:14 · 159 阅读 · 0 评论 -
400. Nth Digit
Given an integern, return thenthdigit of the infinite integer sequence[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...].Example 1:Input: n = 3Output: 3Example 2:Input: n = 11Output: 0Explanation: The 11th digit of the sequence 1, 2, 3, 4, 5, 6,...原创 2021-03-28 22:05:02 · 80 阅读 · 0 评论 -
134. Gas Station
There arengas stations along a circular route, where the amount of gas at theithstation isgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from theithstation to its next(i + 1)thstation. You begin the journe...原创 2021-03-27 16:40:23 · 153 阅读 · 0 评论 -
354. Russian Doll Envelopes俄罗斯套娃信封dp
You are given a 2D array of integersenvelopeswhereenvelopes[i] = [wi, hi]represents the width and the height of an envelope.One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and heigh...原创 2021-03-23 21:31:35 · 173 阅读 · 0 评论 -
403. Frog Jump
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given a list ofstones' positions (in units) in sortedasc..原创 2021-03-22 21:58:57 · 118 阅读 · 0 评论 -
329. Longest Increasing Path in a Matrix dfs+记忆化搜索
https://leetcode.com/problems/longest-increasing-path-in-a-matrix/原创 2021-03-21 22:53:15 · 153 阅读 · 0 评论 -
LFU缓存结构设计
题目描述一个缓存结构需要实现如下功能。set(key, value):将记录(key, value)插入该结构 get(key):返回key对应的value值但是缓存结构中最多放K条记录,如果新的第K+1条记录要加入,就需要根据策略删掉一条记录,然后才能把新记录加入。这个策略为:在缓存结构的K条记录中,哪一个key从进入缓存结构的时刻开始,被调用set或者get的次数最少,就删掉这个key的记录;如果调用次数最少的key有多个,上次调用发生最早的key被删除这就是LFU缓存替换算法。实现原创 2021-03-21 16:13:22 · 379 阅读 · 0 评论 -
求平方根
题目描述实现函数int sqrt(int x).计算并返回x的平方根(向下取整)示例1输入2返回值1题目链接:https://www.nowcoder.com/practice/09fbfb16140b40499951f55113f2166c?tpId=117&tqId=37734&rp=1&ru=%2Fta%2Fjob-code-high&qru=%2Fta%2Fjob-code-high%2Fquestion-ranking&.原创 2021-03-21 11:05:56 · 1269 阅读 · 0 评论 -
设计LRU缓存结构
题目描述设计LRU缓存结构,该结构在构造时确定大小,假设大小为K,并有如下两个功能set(key, value):将记录(key, value)插入该结构 get(key):返回key对应的value值[要求]set和get方法的时间复杂度为O(1) 某个key的set或get操作一旦发生,认为这个key的记录成了最常使用的。 当缓存的大小超过K时,移除最不经常使用的记录,即set或get最久远的。若opt=1,接下来两个整数x, y,表示set(x, y)若opt=2,接下来一个整原创 2021-03-21 10:40:28 · 352 阅读 · 0 评论 -
大数加法
题目描述以字符串的形式读入两个数字,编写一个函数计算它们的和,以字符串形式返回。(字符串长度不大于100000,保证字符串仅由'0'~'9'这10种字符组成)示例1输入"1","99"返回值"100"说明1+99=100 题目链接:https://www.nowcoder.com/practice/11ae12e8c6fe48f883cad618c2e81475?tpId=117&tqId=37842&rp=1&ru=%2Fta%2Fj原创 2021-03-20 22:08:46 · 131 阅读 · 0 评论 -
72. Edit Distance
Given two stringsword1andword2, returnthe minimum number of operations required to convertword1toword2.You have the following three operations permitted on a word:Insert a character Delete a character Replace a characterExample 1:Input:...原创 2021-03-20 16:28:54 · 175 阅读 · 0 评论 -
115. Distinct Subsequences
Given two stringssandt, returnthe number of distinct subsequences ofswhich equalst.A string'ssubsequenceis a new string formed from the original string by deleting some (can be none) of the characters without disturbing the remaining characters'...原创 2021-03-20 14:23:47 · 257 阅读 · 0 评论 -
221. Maximal Square
Given anm x nbinarymatrixfilled with0's and1's,find the largest square containing only1'sand return its area.Example 1:Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]Output: 4...原创 2021-03-20 09:55:30 · 185 阅读 · 0 评论 -
Leetcode 213. House Robber II 2遍dp
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place arearranged in a circle.That means the first house is ...原创 2019-03-12 16:18:54 · 231 阅读 · 0 评论 -
Leetcode 198. House Robber dp
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...原创 2019-03-12 15:07:10 · 163 阅读 · 0 评论 -
91. Decode Ways
A message containing letters fromA-Zcan beencodedinto numbers using the following mapping:'A' -> "1"'B' -> "2"...'Z' -> "26"Todecodean encoded message, all the digits must be grouped then mapped back into letters using the reverse o...原创 2021-03-19 11:10:13 · 180 阅读 · 0 评论 -
Leetcode 174. Dungeon Game dp
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos...原创 2019-03-02 18:44:04 · 186 阅读 · 0 评论 -
980. Unique Paths III
980.Unique Paths IIIHard133288Add to ListShareOn a 2-dimensionalgrid, there are 4 types of squares:1represents the starting square. There is exactly one starting square. 2represents the ending square. There is exactly one ending square. 0r...原创 2021-03-15 16:35:35 · 145 阅读 · 0 评论 -
leetcode 63. Unique Paths II dp
A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...原创 2019-01-19 15:31:27 · 195 阅读 · 0 评论 -
Leetcode 70. Climbing Stairs dp
You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note:Givennwill be a positive...原创 2019-01-20 14:31:05 · 165 阅读 · 0 评论 -
Leetcode 131. Palindrome Partitioning
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.Example:Input:"aab"Output:[ ["aa","b"], ["a","a"...原创 2019-02-13 14:50:50 · 103 阅读 · 0 评论 -
Leetcode 31. Next Permutation
Implementnext permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o...原创 2018-12-24 22:47:59 · 115 阅读 · 0 评论 -
Leetcode 46. Permutations全排列
Given a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]题目链接:https://leetcod...原创 2019-01-09 19:47:10 · 241 阅读 · 0 评论