摘要:
[抄题]: 对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出现的第一个位置(从0开始)。如果不存在,则返回 -1。 如果 source = "source" 和 target = "target",返回 -1。 如果 so 阅读全文
posted @ 2018-03-10 21:55
苗妙苗
阅读(162)
评论(0)
推荐(0)
摘要:
[抄题]: 设计一种方式检查一个链表是否为回文链表。1->2->1 就是一个回文链表。 [暴力解法]: 时间分析: 空间分析: [思维问题]: 以为要从从后往前扫描,不知道调用reverse函数。其实找中点、翻转都是链表中直接能用的API [一句话思路]: 后半截儿反过来以后,相同就同时走。走到头说 阅读全文
posted @ 2018-03-10 19:40
苗妙苗
阅读(170)
评论(0)
推荐(0)
摘要:
[抄题]: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 -- 阅读全文
posted @ 2018-03-10 09:21
苗妙苗
阅读(296)
评论(0)
推荐(0)