随笔分类 -  leetcode

1 2 3 4 5 ··· 7 下一页
摘要:给你一个会议时间安排的数组 intervals ,每个会议时间都会包括开始和结束的时间 intervals[i] = [starti, endi] ,返回 所需会议室的最小数量 。 示例 1: 输入:intervals = [[0,30],[5,10],[15,20]]输出:2 来源:力扣(Leet 阅读全文
posted @ 2022-02-19 14:55 丶Blank 阅读(245) 评论(0) 推荐(0)
摘要:群里看到有人面微软的一面题。 第一种方式,暴力解,二重循环查找sum=k的。 第二种方式,刚看了题解也还是有点晕,主要思路就是前缀和+哈希表。重点是一次循环,边统计当前下标的前缀和 边查找符合要求的前缀和是否已经出现过,并且将出现的次数加到ans中。 第一种方式。 func subarraySum( 阅读全文
posted @ 2022-02-15 00:53 丶Blank 阅读(41) 评论(0) 推荐(0)
摘要:Ok 梳理一下思路,先按照攻击力进行排序,攻击力相同的按照防御力升序排序 if n[i].att == n[j].att { return n[i].def < n[j].def } return n[i].att < n[j].att [{1 27} {3 60} {9 26} {14 6} {1 阅读全文
posted @ 2022-01-28 16:45 丶Blank 阅读(31) 评论(0) 推荐(0)
摘要:LeetCode 147 单链表插入排序,主要知识点,单链表翻转。 单链表翻转关键点只有4步。 1. 暂存Next节点 2. 将当前节点Next 指向Head的Next 3. 将Head的Next指向当前节点 4. 将暂存节点赋值给当前节点 /** * Definition for singly-l 阅读全文
posted @ 2022-01-20 00:09 丶Blank 阅读(51) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2018-09-14 18:01 丶Blank 阅读(271) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2018-09-14 16:10 丶Blank 阅读(215) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2018-09-14 14:16 丶Blank 阅读(220) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2018-09-14 11:13 丶Blank 阅读(241) 评论(0) 推荐(0)
摘要:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文
posted @ 2015-09-22 00:16 丶Blank 阅读(160) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
posted @ 2015-09-20 21:29 丶Blank 阅读(114) 评论(0) 推荐(0)
摘要:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th... 阅读全文
posted @ 2015-09-20 20:25 丶Blank 阅读(156) 评论(0) 推荐(0)
摘要:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, givenn... 阅读全文
posted @ 2015-09-20 17:09 丶Blank 阅读(175) 评论(0) 推荐(0)
摘要:Given a positive integern, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum ton.For example, givenn=12, return... 阅读全文
posted @ 2015-09-20 17:03 丶Blank 阅读(147) 评论(0) 推荐(0)
摘要:After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This t... 阅读全文
posted @ 2015-09-20 16:44 丶Blank 阅读(161) 评论(0) 推荐(0)
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ... 阅读全文
posted @ 2015-09-20 16:39 丶Blank 阅读(206) 评论(0) 推荐(0)
摘要:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2015-09-17 21:09 丶Blank 阅读(171) 评论(0) 推荐(0)
摘要:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.计算N皇后的合法解的数量。解题思路:这次使用了更优化的... 阅读全文
posted @ 2015-09-16 15:46 丶Blank 阅读(157) 评论(0) 推荐(0)
摘要:Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For exampl... 阅读全文
posted @ 2015-09-16 15:42 丶Blank 阅读(182) 评论(0) 推荐(0)
摘要:Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].题目大意:给定一个组区间,实... 阅读全文
posted @ 2015-09-11 18:46 丶Blank 阅读(164) 评论(0) 推荐(0)
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c... 阅读全文
posted @ 2015-09-11 16:21 丶Blank 阅读(168) 评论(0) 推荐(0)

1 2 3 4 5 ··· 7 下一页