IncredibleThings

导航

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 28 下一页

2018年9月23日 #

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) 编辑

2018年9月21日 #

LeetCode - Is Graph Bipartite?

摘要: 原来输入数组中的graph[i],表示顶点i所有相邻的顶点,比如对于例子1来说,顶点0和顶点1,3相连,顶点1和顶点0,2相连,顶点2和结点1,3相连,顶点3和顶点0,2相连。这道题让我们验证给定的图是否是二分图,所谓二分图,就是可以将图中的所有顶点分成两个不相交的集合,使得同一个集合的顶点不相连。 阅读全文

posted @ 2018-09-21 11:35 IncredibleThings 阅读(127) 评论(0) 推荐(0) 编辑

2018年9月20日 #

LeetCode - Rotate String

摘要: We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after on... 阅读全文

posted @ 2018-09-20 20:29 IncredibleThings 阅读(104) 评论(0) 推荐(0) 编辑

LeetCode – Smallest Rotation with Highest Score

摘要: 暴力解法会超时 这道题给了我们一个长度为N的数组,说是数组中的数字的范围都在[0, N]之间,然后定义了一个旋转操作,比如在位置K进行旋转,数组在K位置断开,新数组以A[k]为开头数字,断开的前半段数组直接拼到末尾即可。然后又定义了一种积分规则,说是如果某个坐标位置大于等于其数字的话,得1分,让我们 阅读全文

posted @ 2018-09-20 11:22 IncredibleThings 阅读(136) 评论(0) 推荐(0) 编辑

LeetCode – Most Common Word

摘要: Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answe... 阅读全文

posted @ 2018-09-20 10:28 IncredibleThings 阅读(174) 评论(0) 推荐(0) 编辑

2018年9月19日 #

LeetCode - Rectangle Overlap

摘要: 分情况讨论, 讨论不可能相交的四种情况(横轴与横轴比较,纵轴与纵轴比较) 阅读全文

posted @ 2018-09-19 19:40 IncredibleThings 阅读(242) 评论(0) 推荐(0) 编辑

LeetCode – Lemonade Change

摘要: 这是一个关于找零的问题。首先,因为初始没有资本,而且每份柠檬水的售价是5美元。因此,5美元是最“珍贵”的找零资源。 如果顾客给的是10美元,那么只能找给他一张5美元的。 如果顾客给的是20美元,因为5美元比较稀缺,因此如果有10美元的钞票,则优先找给他10美元,然后再找一张5美元;否则的话,就直接给 阅读全文

posted @ 2018-09-19 19:15 IncredibleThings 阅读(126) 评论(0) 推荐(0) 编辑

LeetCode – All Nodes Distance K in Binary Tree

摘要: 题意是让我们在一颗二叉树中,给定节点 Target, 寻找和target节点距离 为 K的所有节点,我们可以把这颗树看成一个无向图, 没有顺序就意味着,二叉树的旁边的指节也是可以算距离的。 我们可以先把二叉树转化为无向图,再在图中进行 BFS 搜索应该就可以得到答案。 阅读全文

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

上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 28 下一页