摘要:
这道题难度较低,没有必要作说明。 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it we 阅读全文
摘要:
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 实现strStr()。 返回haystack中第 阅读全文
摘要:
这道题跟26题很类似,并且有官方的答案。看了官方的答案之后发现写得特别巧,自己做的题太少思路太窄。有意思的是我的算法的时间复杂度是O(N^2),官方的是O(N),我的实际运行时间还少了2ms。 iven an array and a value, remove all instances of th 阅读全文
摘要:
算法和数据结构这东西,真的是需要常用常练。这道看似简单的链表合并题,难了我好几个小时,最后还是上网搜索了一种不错算法。后期复习完链表的知识我会将我自己的实现代理贴上。 这个算法巧就巧在用了递归的思想,按照常规方法也能求得,但是就未免太复杂了。 Merge two sorted linked list 阅读全文
摘要:
09.18更新算法采用栈的思想解决,方法①所示。 本题主要是找是否有匹配的字符串,因为还没有复习到栈之类的知识点,只能还是采用暴力方法了,后期会补上更加优化的算法。我的思路就是先遍历一遍找是否有匹配的符号,有的话就删除,然后继续遍历,直至结束。 Given a string containing j 阅读全文