IncredibleThings

导航

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 28 下一页

2018年11月18日 #

LeetCode - Word Subsets

摘要: 这道题的核心就是理解对于B的处理: 先来理解题目,题目强调的是单个字母,不存在字母顺序问题,所以只要统计出B中每个小写字母,在所有的单词中出现次数最高的那个数(例如,B = ["loo","eo"],那么o 最大的出现次数为2, 因为在"loo"出现了两次,在"eo"出现了一次,所以以最大的为准), 阅读全文

posted @ 2018-11-18 11:25 IncredibleThings 阅读(101) 评论(0) 推荐(0) 编辑

LeetCode - Unique Email Addresses

摘要: Hash 阅读全文

posted @ 2018-11-18 09:41 IncredibleThings 阅读(116) 评论(0) 推荐(0) 编辑

LeetCode - Beautiful Array

摘要: 这道题是用divide and conque 做的。参考自: https://blog.csdn.net/lwgkzl/article/details/83502656 因为2*A[k]是偶数,如果要求2*A[K]!=A[I]+A[J]那么可以构造位置在A[k]左边的全部放奇数,位置在A[k]右边的 阅读全文

posted @ 2018-11-18 09:19 IncredibleThings 阅读(196) 评论(0) 推荐(0) 编辑

2018年11月16日 #

LeetCode - Number of Recent Calls

摘要: 用queue 阅读全文

posted @ 2018-11-16 12:48 IncredibleThings 阅读(208) 评论(0) 推荐(0) 编辑

LeetCode - Minimum Area Rectangle

摘要: 核心思想是利用对角线的原理定下两个点,根据对角线在找到另外两个点 如何把一个array pair存到hash里,第一次我用了int -> string, 超时了 第二次看了别人的代码, 原来可以按照把每一个pair的x存成key,y轴存成一个hashset。 阅读全文

posted @ 2018-11-16 12:04 IncredibleThings 阅读(227) 评论(0) 推荐(0) 编辑

2018年10月19日 #

LeetCode - Convert BST to Greater Tree

摘要: 反着中序遍历, 就会从大到小排序,注意要用一个 global 变量保存状态。 阅读全文

posted @ 2018-10-19 00:03 IncredibleThings 阅读(98) 评论(0) 推荐(0) 编辑

2018年10月18日 #

LeetCode - Count Primes

摘要: 这个图事实上就道出了这个算法是怎么进行的。使用一个长度是n的hash表,最開始这个hash表中的全部元素都是没有被处理的,从2開始遍历,假设这个元素没有被处理,那么将素数的个数加1,然后将2*2,2*3,2*4……2* k( 2* k < n)标记为已经被处理了的。接着開始处理3,同理将3*2,3* 阅读全文

posted @ 2018-10-18 22:32 IncredibleThings 阅读(89) 评论(0) 推荐(0) 编辑

2018年10月16日 #

LeetCode - Binary Tree Right Side View

摘要: Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4... 阅读全文

posted @ 2018-10-16 05:21 IncredibleThings 阅读(82) 评论(0) 推荐(0) 编辑

2018年10月15日 #

Two Sum II - Input array is sorted

摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers... 阅读全文

posted @ 2018-10-15 07:09 IncredibleThings 阅读(98) 评论(0) 推荐(0) 编辑

2018年10月10日 #

LeetCode - Word Break

摘要: BFS需要一个队列来实现。首先根据在dict中查找s的前缀,如果有,加入队列中,作为遍历的“根”节点。比如上述的第二个例子,先入队的有"car"和"ca"两项; 当队列不为空时,队头top出列,令一个临时字符串temp是从s与top匹配后的字符开始到结束;如果此时temp是空,说明已经匹配完了,直接 阅读全文

posted @ 2018-10-10 19:23 IncredibleThings 阅读(82) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 28 下一页