自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【leetcode】【medium】【每日一题】912. Sort an Array​​​​​​​

912. Sort an ArrayGiven an array of integersnums, sort the array in ascending order.Example 1:Input: nums = [5,2,3,1]Output: [1,2,3,5]Example 2:Input: nums = [5,1,1,2,0,0]Output: [0,0,...

2020-03-31 16:47:10 104

原创 【leetcode】【medium】【每日一题】1162. As Far from Land as Possible​​​​​​​

1162. As Far from Land as PossibleGiven an N x Ngridcontaining only values0and1, where0represents waterand1represents land, find a water cell such that its distance to the nearest land cel...

2020-03-31 16:29:58 133

原创 【leetcode】【easy】【每日一题】面试题62. 圆圈中最后剩下的数字​​​​​​​

面试题62. 圆圈中最后剩下的数字0,1,,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字。求出这个圆圈里剩下的最后一个数字。例如,0、1、2、3、4这5个数字组成一个圆圈,从数字0开始每次删除第3个数字,则删除的前4个数字依次是2、0、4、1,因此最后剩下的数字是3。示例 1:输入: n = 5, m = 3输出:3示例 2:输入: ...

2020-03-31 15:46:27 113

原创 【leetcode】【medium】【每日一题】820. Short Encoding of Words

820. Short Encoding of WordsGiven a list of words, we may encode it by writing a reference stringSand a list of indexesA.For example, if the list of words is["time", "me", "bell"], we can writ...

2020-03-28 17:59:54 90

原创 【leetcode】【easy】【每日一题】914. X of a Kind in a Deck of Cards​​​​​​​

914. X of a Kind in a Deck of CardsIn a deck of cards, each card has an integer written on it.Returntrueif and only if you can chooseX >= 2such thatit is possible to split the entire deck...

2020-03-27 16:51:40 124

原创 【leetcode】【easy】【每日一题】999. Available Captures for Rook​​​​​​​

999. Available Captures for RookOn an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns. These are given as characters 'R', '.', 'B', and '...

2020-03-26 16:40:32 199

原创 【leetcode】【medium】474. Ones and Zeroes​​​​​​​

474. Ones and ZeroesIn the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.For now, suppose you are a dominator ofm0sandn1srespe...

2020-03-26 10:47:35 67

原创 【leetcode】【easy】【每日一题】892. Surface Area of 3D Shapes​​​​​​​

892. Surface Area of 3D ShapesOn aN*Ngrid, we place some1 * 1 * 1cubes.Each valuev = grid[i][j]represents a tower ofvcubes placed on top of grid cell(i, j).Return the total surface ar...

2020-03-25 16:56:04 104

原创 【leetcode】【medium】215. Kth Largest Element in an Array​​​​​​​

215. Kth Largest Element in an ArrayFind thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input:...

2020-03-25 13:10:26 57

原创 【leetcode】【easy】703. Kth Largest Element in a Stream​​​​​​​

703. Kth Largest Element in a StreamDesign a class to findthekth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.YourKthLa...

2020-03-25 11:38:08 96

原创 【leetcode】【hard】493. Reverse Pairs​​​​​​​

493. Reverse PairsGiven an arraynums, we call(i, j)animportant reverse pairifi < jandnums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array....

2020-03-25 00:52:35 74

原创 【leetcode】【easy】【每日一题】面试题 17.16. The Masseuse LCCI​​​​​​​

面试题 17.16. The Masseuse LCCIA popular masseuse receives a sequence of back-to-back appointment requests and is debating which ones to accept. She needs a break between appointments and therefore she...

2020-03-24 22:25:34 318

原创 【kick start】2020 A round

这里的代码只贴solution函数,代码框架请看这篇:kick start代码框架。比赛链接:https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc7赛后总结这轮打的太坎坷啦。题目很简单,但是除了各种状况。首先是第一题卡在输出格式上,不知道为什么使用以前的代码竟然还能出错,搞了一小时的输...

2020-03-23 19:39:07 390

原创 【kick start】代码框架

本篇记录kick start的代码框架,方便重复使用,避免发生因输出格式不符而产生的bug。void solve(){ // 每个case里的逻辑 ll n,b; cin >> n >> b; // 读取输入 ll res = 0; // 记录结果 ll cost[n]; // 记录输入 ...

2020-03-23 16:34:20 136

原创 【leetcode】【easy】【每日一题】876. Middle of the Linked List​​​​​​​

876. Middle of the Linked ListGiven a non-empty, singlylinked list with head nodehead, returnamiddle node of linked list.If there are two middle nodes, return the second middle node.Example ...

2020-03-23 16:17:35 126

原创 【leetcode】【medium】【每日一题】945. Minimum Increment to Make Array Unique​​​​​​​

945. Minimum Increment to Make Array UniqueGiven an array of integers A, amoveconsists of choosing anyA[i], and incrementing it by1.Return the least number of moves to make every value inAun...

2020-03-23 00:15:17 68

原创 【leetcode】【mudium】684. Redundant Connection​​​​​​​

684. Redundant ConnectionIn this problem, a tree is anundirectedgraph that is connected and has no cycles.The given input is a graph that started as a tree with N nodes (with distinct values...

2020-03-22 23:28:52 93

原创 【leetcode】【hard】128. Longest Consecutive Sequence​​​​​​​

128. Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input:...

2020-03-22 00:47:34 74

原创 【leetcode】【medium】【每日一题】365. Water and Jug Problem​​​​​​​

365. Water and Jug ProblemYou are given two jugs with capacitiesxandylitres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactl...

2020-03-21 23:14:25 132

原创 【leetcode】【medium】718. Maximum Length of Repeated Subarray​​​​​​​

718. Maximum Length of Repeated SubarrayGiven two integer arraysAandB, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Out...

2020-03-21 19:50:24 92

原创 【leetcode】【easy】【每日一题】面试题40. 最小的k个数​​​​​​​

面试题40. 最小的k个数输入整数数组arr,找出其中最小的k个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。示例 1:输入:arr = [3,2,1], k = 2输出:[1,2] 或者 [2,1]示例 2:输入:arr = [0,1,2,1], k = 1输出:[0]限制:0 <= k <=...

2020-03-21 01:14:13 79

原创 【leetcode】【easy】28. Implement strStr()​​​​​​​

28. Implement strStr()ImplementstrStr().Return the index of the first occurrence of needle in haystack, or-1if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = ...

2020-03-21 01:06:43 79

原创 【leetcode】【easy】【每日一题】409. Longest Palindrome

409. Longest PalindromeGiven a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for ...

2020-03-19 23:54:27 56

原创 【leetcode】【easy】【每日一题】836. Rectangle Overlap​​​​​​​

836. Rectangle OverlapA rectangle isrepresented as alist[x1, y1, x2, y2], where(x1, y1)are the coordinates of its bottom-left corner, and(x2,y2)are the coordinates of its top-right corner....

2020-03-18 23:34:18 89

原创 【leetcode】【easy】【每日一题】1160. Find Words That Can Be Formed by Characters​​​​​​​

1160. Find Words That Can Be Formed by CharactersYou are given an array of stringswordsand a stringchars.A string isgoodifit can be formed bycharacters fromchars(each charactercan only b...

2020-03-17 23:02:55 104

原创 【leetcode】【easy】【每日一题】面试题 01.06. Compress String LCCI

面试题 01.06. Compress String LCCIImplement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "comp...

2020-03-16 16:57:35 110

原创 【leetcode】第 180 场周赛

赛后总结这场状态还不错,可惜遇到了知识盲点,以及hard虽然有思路但没能快速实现。差一点就能完成flag了。第1题:弄清思路后就很快,出了一个低级错误,耽误了很久。第2题:程序设计类的题,没什么难度。第3题:平衡树是弱项,需要补一下。第4题:dp题,想出来了解法,但实现稍复杂,速度太慢。优点1.状态稳定,该做的做完了。缺点&改进1.低级错误!2.平衡...

2020-03-15 14:19:01 157

原创 【leetcode】【medium】【每日一题】695. Max Area of Island

695. Max Area of IslandGiven a non-empty 2D arraygridof 0's and 1's, anislandis a group of1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edg...

2020-03-15 14:05:31 93

原创 【leetcode】【medium】377. Combination Sum IV

377. Combination Sum IVGiven 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-03-14 17:05:32 94

原创 【leetcode】【medium】416. Partition Equal Subset Sum​​​​​​​

416. Partition Equal Subset SumGiven anon-emptyarray containingonly positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal...

2020-03-14 16:38:22 79

原创 【leetcode】【medium】376. Wiggle Subsequence

376. Wiggle SubsequenceA sequence of numbers is called awiggle sequenceif the differences between successive numbers strictly alternate between positive and negative. The first difference (if one ...

2020-03-14 15:11:02 64

原创 【leetcode】【easy】【每日一题】1071. Greatest Common Divisor of Strings

1071. Greatest Common Divisor of StringsFor stringsSandT, we say "TdividesS" if and only ifS = T + ... + T (Tconcatenated with itself 1 or more times)Return the largest stringXsuch th...

2020-03-14 00:17:23 110

原创 【leetcode】【medium】300. Longest Increasing Subsequence

300. Longest Increasing SubsequenceGiven an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation: The longes...

2020-03-14 00:13:41 91

原创 【leetcode】【medium】229. Majority Element II​​​​​​​

229. Majority Element IIGiven an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times.Note:The algorithm should run in linear time and in O(1) space.Example 1:Input...

2020-03-13 22:49:40 63

原创 【leetcode】【easy】【每日一题】169. Majority Element​​​​​​​

169. Majority ElementGiven an array of sizen, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋times.You may assume that the array is non-empty and th...

2020-03-13 21:37:04 59

原创 【leetcode】【easy】【每日一题】1013. Partition Array Into Three Parts With Equal Sum​​​​​​​

1013. Partition Array Into Three Parts With Equal SumGiven an arrayAof integers, returntrueif and only if we can partition the array into threenon-emptyparts with equal sums.Formally, we can...

2020-03-11 20:54:31 97

原创 【leetcode】第 179 场周赛

赛后反思这场有点可惜,差一点能完成flag。第1题:超级简单题,主要是题意理解。第2题:难在题目理解,编程上是一些小trick。第3题:树递归的题目,但是从叶子向根递归,题目出得不错,当时没有想到。第4题:看到题就没有思路,暂时先不分析。缺点&改进:1.做题量太少,很多类型的题只做过基础版本,还没遇到比较灵活的,一旦遇到就显得脑子转不过来。2.继续减少低级错...

2020-03-10 16:39:02 202

原创 【leetcode】【easy】【每日一题】543. Diameter of Binary Tree​​​​​​​

543. Diameter of Binary TreeGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongestpath between any two nodes in ...

2020-03-10 14:52:04 74

原创 【leetcode】第 21 场双周赛

赛后总结虽然结果上没有提升,但是过程中有了一些进步,稳定提升中。第1题:10分钟左右,还可以练练速度。第2题:蒙圈了,尝试了一会儿发现思路不够清晰,就放弃了。第3题:思路很快,变成很快,但是遇到了内存的坑,卡住了很久,不过能调出来还挺开心的。第4题:不难,但当时思路很乱,如果能多一点冷静分析结果应该会更好。优点1.心态更好了。2.在容器选择上更加熟练了。3.简单...

2020-03-09 18:41:16 223

原创 【leetcode】【easy】【每日一题】121. Best Time to Buy and Sell Stock

121. Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (i.e., buy...

2020-03-09 14:44:42 87

空空如也

空空如也

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

TA关注的人

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