摘要:
Validate if a given string is numeric. Some examples: "0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for th 阅读全文
阅读排行榜
[LeetCode 621] Task Scheduler
2017-11-13 00:52 by naturesound, 417 阅读, 收藏,
摘要:
这题虽是M难度,却花了我比Hard难度还多的时间。 1.刚开始是想用一个堆排序来实现,排序的比较标准是两个:1.任务的最早启动时间;2.任务的重复次数。并且把1作为第一比较。 后来发现这个思路有误:只要A,B的最早启动时间都小于当前时间,不管A和B哪个最早启动时间更小,这时只需要考虑重复次数:哪个重 阅读全文
[LeetCode] 129 Sum Root to Leaf Numbers 求根到叶节点数字之和
2017-04-26 06:30 by naturesound, 192 阅读, 收藏,
摘要:
此题题意是求所有从根结点到叶节点的路径转化为数字后之和。 因为是二叉树,容易想到是用递归求解。 整体思想是从根到叶子进行遍历,其中不断保存当前的中间结果(上一层的结果乘以10后加上当前层根节点的数值)并通过参数向下传递。。。 到达叶子节点时可以逐层返回最终结果。解法不难,但有几个细节需要考虑清楚。 阅读全文
LeetCode 273. Integer to English Words
2017-11-12 00:26 by naturesound, 191 阅读, 收藏,
摘要:
此题是一个数字字符转化类问题。没有什么复杂的技巧,只要想清楚2个转化的规律: 1,此题给出的非负数字上限是2^31-1,大约是十亿的数量级(2^10 = 1024, (2^10)^3 ~1billion)。而我们已知每1000进位方式有三种后缀,thousand, million和billion,这 阅读全文
[LeetCode 297] Serialize and deserialize binary tree
2017-11-18 13:19 by naturesound, 178 阅读, 收藏,
摘要:
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or 阅读全文
浙公网安备 33010602011771号