IncredibleThings

导航

2018年9月23日 #

LeetCode - Kth Largest Element in a Stream

摘要: 遍历数组时将数字加入优先队列(堆),一旦堆的大小大于k就将堆顶元素去除,确保堆的大小为k。遍历完后堆顶就是返回值。 阅读全文

posted @ 2018-09-23 23:46 IncredibleThings 阅读(92) 评论(0) 推荐(0) 编辑

LeetCode - Flood Fill

摘要: An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, sc) representing the starting pixel (row and col... 阅读全文

posted @ 2018-09-23 21:05 IncredibleThings 阅读(136) 评论(0) 推荐(0) 编辑

LeetCode - Daily Temperatures

摘要: 竟然暴力解法也可AC: 另一种使用stack的解法: 阅读全文

posted @ 2018-09-23 08:21 IncredibleThings 阅读(93) 评论(0) 推荐(0) 编辑

LeetCode - Partition Labels

摘要: A 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 of integers representing t... 阅读全文

posted @ 2018-09-23 08:06 IncredibleThings 阅读(115) 评论(0) 推荐(0) 编辑

LeetCode - Reorganize String

摘要: 这道题给了我们一个字符串,让我们重构这个字符串,使得相同的字符不会相邻,如果无法做到,那么就返回空串,题目中的例子很好的说明了这一点。那么,如果先不考虑代码实现,让你来手动重构的话,该怎么做呢?我们要做的就是把相同的字符分开。比如例子1中,两个a相邻了,所以我们把第二个a和后面的b交换位置,这样分开 阅读全文

posted @ 2018-09-23 06:02 IncredibleThings 阅读(115) 评论(0) 推荐(0) 编辑