![](https://img-blog.csdnimg.cn/20200327092807883.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
OJ
文章平均质量分 78
oj
小白算法习题记录本
一个刚学算法的超级无敌小白痴。博客里所有的文章都是用来记录我做题时候敲下的代码的,全是水货,无贡献,经不起深敲,主页也没有浏览的必要,蟹蟹!
展开
-
12. Integer to Roman
Integer to RomanRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 500M 1000For example, 2.原创 2020-11-18 20:48:21 · 211 阅读 · 0 评论 -
119. Pascal‘s Triangle II
Pascal’s Triangle IIGiven an integer rowIndex, return the rowIndexth row of the Pascal’s triangle.Notice that the row index starts from 0.In Pascal’s triangle, each number is the sum of the two numbers directly above it.Follow up:Could you optimize.原创 2020-11-02 20:41:41 · 127 阅读 · 0 评论 -
1337. The K Weakest Rows in a Matrix
The K Weakest Rows in a MatrixGiven a m * n matrix mat of ones (representing soldiers) and zeros (representing civilians), return the indexes of the k weakest rows in the matrix ordered from the weakest to the strongest.A row i is weaker than row j, if.原创 2020-10-28 10:55:06 · 97 阅读 · 0 评论 -
38. Count and Say
Count and SayThe count-and-say sequence is a sequence of digit strings defined by the recursive formula:countAndSay(1) = “1”countAndSay(n) is the way you would “say” the digit string from countAndSay(n-1), which is then converted into a different digi.原创 2020-10-23 19:30:30 · 232 阅读 · 0 评论 -
1493. Longest Subarray of 1‘s After Deleting One Element
Longest Subarray of 1’s After Deleting One ElementGiven a binary array nums, you should delete one element from it.Return the size of the longest non-empty subarray containing only 1’s in the resulting array.Return 0 if there is no such subarray.Exam.原创 2020-10-09 20:36:11 · 123 阅读 · 0 评论 -
1253. Reconstruct a 2-Row Binary Matrix
Reconstruct a 2-Row Binary MatrixMedium869Add to ListShareGiven the following details of a matrix with n columns and 2 rows :The matrix is a binary matrix, which means each element in the mat...原创 2020-04-14 12:18:36 · 167 阅读 · 0 评论 -
1276. Number of Burgers with No Waste of Ingredients
Number of Burgers with No Waste of IngredientsMedium6177Add to ListShareGiven two integers tomatoSlices and cheeseSlices. The ingredients of different burgers are as follows:Jumbo Burger: 4 t...原创 2020-04-14 11:47:00 · 155 阅读 · 0 评论 -
1282. Group the People Given the Group Size They Belong To
Group the People Given the Group Size They Belong ToMedium194121Add to ListShareThere are n people whose IDs go from 0 to n - 1 and each person belongs exactly to one group. Given the array gr...原创 2020-04-14 11:13:14 · 209 阅读 · 0 评论 -
1296. Divide Array in Sets of K Consecutive Numbers
Divide Array in Sets of K Consecutive NumbersMedium19919Add to ListShareGiven an array of integers nums and a positive integer k, find whether it’s possible to divide this array into sets of k...原创 2020-04-13 16:41:47 · 161 阅读 · 0 评论 -
1400. Construct K Palindrome Strings
Construct K Palindrome StringsMedium699Add to ListShareGiven a string s and an integer k. You should construct k non-empty palindrome strings using all the characters in s.Return True if you ...原创 2020-04-13 14:46:33 · 243 阅读 · 0 评论 -
2020中南大学研究生招生夏令营机试题
2020中南大学研究生招生夏令营机试题1.缺失的彩虹1.缺失的彩虹题目描述众所周知,彩虹有7种颜色,我们给定七个 字母和颜色 的映射,如下所示:‘A’ -> “red”‘B’ -> “orange”‘C’ -> “yellow”‘D’ -> “green”‘E’ -> “cyan”‘F’ -> “blue”‘G’ -> “purple”...原创 2020-04-12 22:37:14 · 526 阅读 · 0 评论 -
6. ZigZag Conversion
ZigZag ConversionMedium14794240Add to ListShareThe string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed ...原创 2020-04-08 20:29:46 · 117 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters
Longest Substring Without Repeating CharactersMedium8259500Add to ListShareGiven a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”O...原创 2020-04-08 17:43:57 · 115 阅读 · 0 评论 -
171. Excel Sheet Column Number(int不行就换unsigned long)
Excel Sheet Column NumberEasy807140Add to ListShareGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -&...原创 2020-04-08 16:38:14 · 131 阅读 · 0 评论 -
28. Implement strStr()
Implement strStr()Easy13571740Add to ListShareImplement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: hay...原创 2020-04-08 15:05:11 · 80 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Remove Duplicates from Sorted ArrayEasy22194634Add to ListShareGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do n...原创 2020-04-08 14:49:37 · 63 阅读 · 0 评论 -
20. Valid Parentheses,括号匹配,一看就懂
Valid ParenthesesEasy4411203Add to ListShareGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:...原创 2020-04-08 14:23:05 · 89 阅读 · 0 评论 -
13. Roman to Integer
Roman to IntegerEasy19173305Add to ListShareRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X ...原创 2020-04-08 14:11:16 · 78 阅读 · 0 评论 -
9. Palindrome Number
Palindrome NumberEasy20581499Add to ListShareDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: ...原创 2020-04-08 13:56:52 · 89 阅读 · 0 评论 -
1088: 回文串询问Ⅱ
题目描述PIPI要考考你对回文串的掌握了~现在有一个长度为n的字符串S,PIPI对此有q个询问,每次询问S中某个连续区间(从1开始)中回文子串的数目。输入多组数据。第一行为两个个整数n,q(1<=n<=1000,1<=q<=100000)第二行为一个长为n的字符串S。接下来q行,每行两个整数l,r,表示询问S中区间[l,r]中回文子串的数目。保证l<=r...原创 2020-04-07 14:33:46 · 507 阅读 · 0 评论 -
1090: 最少回文串分割
题目描述PIPI听说同学们最近学习了回文串算法,现在它想考考你~PIPI给你一个只含小写字母的字符串,请你将这个字符串拆分成几段,要求每段都是回文串,同时要求段数尽可能少。racecar本身为回文串,故答案为1fastcar只能拆成’f’,‘a’,‘s’,‘t’,‘c’,‘a’,‘t’,答案为7aaabcac可以拆成’aaa’,‘b’,‘cac’,答案为3输入多组输入第一行为一个字...原创 2020-04-07 12:49:47 · 383 阅读 · 0 评论 -
1070: PIPI的数组
题目描述PIPI现在有一个全部为正整数组成的数组,他想知道元素 v 第 k次出现在数组中的位置,胖虎能帮帮PIPI吗?PIPI是个好奇心很重的人,他会有m次询问哦~输入输入包含多组测试样例。对于每一组测试样例,第一行包含两个正整数 n,m .代表数组的长度和询问的次数。 (1<=n,m<=105)第二行包括n个正整数,每个正整数 v < 106。接下来包含m组询问,...原创 2020-04-06 21:20:18 · 180 阅读 · 0 评论 -
1041: 最大子矩阵
题目描述给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。输入输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0<m,n<1000 AND 0<x<=m AND 0<y<=n),表示给定的矩形有m行n列。接下来这个矩阵,有m行,每行有n个不大于1000的正整数。输出对...原创 2020-04-06 15:55:57 · 579 阅读 · 0 评论 -
785. Is Graph Bipartite?
Is Graph Bipartite?MediumGiven an undirected graph, return true if and only if it is bipartite.Recall that a graph is bipartite if we can split it’s set of nodes into two independent subsets A an...原创 2020-04-05 22:12:29 · 128 阅读 · 0 评论 -
332. Reconstruct Itinerary,涉及multiset的运用
Reconstruct ItineraryMediumGiven a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man...原创 2020-04-05 17:43:48 · 80 阅读 · 0 评论 -
210. Course Schedule II
Course Schedule IIMediumThere are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, w...原创 2020-04-05 12:46:45 · 92 阅读 · 0 评论 -
207. Course Schedule
Course ScheduleMediumThere are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.Some courses may have prerequisites, for example to take course 0 you have to first t...原创 2020-04-05 12:36:19 · 120 阅读 · 0 评论 -
8. String to Integer (atoi)
String to Integer (atoi)MediumImplement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character ...原创 2020-04-05 12:19:12 · 67 阅读 · 0 评论 -
377. Combination Sum IV
Combination Sum IVMediumGiven an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2...原创 2020-04-03 12:56:25 · 97 阅读 · 0 评论 -
120. Triangle(动态规划两种解法,空间优化)
TriangleMediumGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[[2],[3,4],[...原创 2020-04-01 13:17:15 · 198 阅读 · 0 评论 -
63. Unique Paths II
Unique Paths IIMediumA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot i...原创 2020-03-31 23:09:06 · 88 阅读 · 0 评论 -
984. String Without AAA or BBB
String Without AAA or BBBMediumGiven two integers A and B, return any string S such that:S has length A + B and contains exactly A ‘a’ letters, and exactly B ‘b’ letters;The substring ‘aaa’ does...原创 2020-03-29 17:21:24 · 82 阅读 · 0 评论 -
955. Delete Columns to Make Sorted II
Delete Columns to Make Sorted IIMediumWe are given an array A of N lowercase letter strings, all of the same length.Now, we may choose any set of deletion indices, and for each string, we delete ...原创 2020-03-29 13:41:58 · 99 阅读 · 0 评论 -
767. Reorganize String
Reorganize StringMediumGiven a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.If possible, output any possible result. I...原创 2020-03-28 00:05:14 · 81 阅读 · 0 评论 -
763. Partition Labels
Partition LabelsMediumA string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list o...原创 2020-03-28 00:04:40 · 107 阅读 · 0 评论 -
738. Monotone Increasing Digits
Monotone Increasing DigitsMediumGiven a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits.(Recall that an integer has monotone increa...原创 2020-03-28 00:00:41 · 83 阅读 · 0 评论 -
714. Best Time to Buy and Sell Stock with Transaction Fee
Best Time to Buy and Sell Stock with Transaction FeeMediumYour are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer ...原创 2020-03-27 23:59:34 · 274 阅读 · 0 评论 -
659. Split Array into Consecutive Subsequences
Split Array into Consecutive SubsequencesMediumGiven an array nums sorted in ascending order, return true if and only if you can split it into 1 or more subsequences such that each subsequence con...原创 2020-03-27 23:58:51 · 260 阅读 · 0 评论 -
452. Minimum Number of Arrows to Burst Balloons
Minimum Number of Arrows to Burst BalloonsMediumThere are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the h...原创 2020-03-27 23:58:19 · 88 阅读 · 0 评论 -
435. Non-overlapping Intervals
Non-overlapping IntervalsMediumGiven a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Example 1:Input: [[1,2],...原创 2020-03-27 23:57:54 · 146 阅读 · 0 评论