GithubHelp home page GithubHelp logo

leetcode-practice's Introduction

已完成:

  1. 1. Two Sum

    Click here to see analysis

    次数 时间 内容 日期
    1 20min 分析+实现+总结+测试 2019.04.09
  2. 2. Add Two Numbers

    Click here to see analysis

    次数 时间 内容 日期
    1 20min 分析+实现+总结+测试 2019.04.09
  3. 19. Remove Nth Node From End of List

    Click here to see analysis

    次数 时间 内容 日期
    1 40min 分析+实现(7min)+总结+测试 2019.04.09
  4. 20. Valid Parentheses

    Click here to see analysis

    次数 时间 内容 日期
    1 16min 分析+实现+总结+测试 2019.04.09
  5. 21. Merge Two Sorted Lists

    Click here to see analysis

    次数 时间 内容 日期
    1 40min 分析+实现+总结+测试 2019.04.09
  6. 141. Linked List Cycle

    Click here to see analysis

    次数 时间 内容 日期
    1 20min 分析+实现+总结+测试 2019.04.09
  7. 155. Min Stack

    Click here to see analysis

    次数 时间 内容 日期
    1 32min 分析+实现+总结+测试 2019.04.09
  8. 206. Reverse Linked List

    Click here to see analysis

    次数 时间 内容 日期
    1 38min 分析+实现+总结+测试 2019.04.10
  9. 232. Implement Queue using Stacks

    Click here to see analysis

    次数 时间 内容 日期
    1 33min 分析+实现+总结+测试 2019.04.10
  10. 234. Palindrome Linked List

    Click here to see analysis

    次数 时间 内容 日期
    1 60min 分析+实现+总结+测试 2019.04.10
    2 20min 实现 2019.04.10
    3 7min 实现 2019.04.10
  11. 328. Odd Even Linked List

    Click here to see analysis

    次数 时间 内容 日期
    1 60min 分析+实现+总结+测试 2019.04.10
    2 4min 实现 2019.04.10
  12. 844. Backspace String Compare

    Click here to see analysis

    次数 时间 内容 日期
    1 60min 分析+实现+总结+测试 2019.04.10
  13. 876. Middle of the Linked List

    Click here to see analysis

    次数 时间 内容 日期
    1 60min 分析+实现(4min)+总结+测试 2019.04.10
  14. 224. Basic Calculator

    Click here to see analysis

    次数 时间 内容 日期
    1 60min 分析+迭代实现+总结+测试 2019.04.12
    2 33min 递归 2019.04.13
  15. 15. 3Sum

    Click here to see analysis

    次数 时间 内容 日期
    1 180min 实现(有bug)+测试 2019.04.14
    2 120min 实现 2019.04.15
    2 100min 分析+优化+回顾总结 2019.04.17
  16. 1029. Two City Scheduling

    次数 时间 内容 日期
    1 180min 实现+测试 2019.04.21
    2 120min 实现 2019.04.22
  17. 650. 2 Keys Keyboard

    次数 时间 内容 日期
    1 180min 实现+测试 2019.04.22
  18. 605. Can Place Flowers

    次数 时间 内容 日期
    1 180min 实现+测试 2019.04.23
  19. 606. Construct String from Binary Tree

    次数 时间 内容 日期
    1 180min 实现+测试 2019.04.24
  20. 542. 01 Matrix

    次数 时间 内容 日期
    1 180min 实现+测试 2019.04.24

总结:

  1. 先想解决思路,不必考虑复杂度,也不必考虑数据结构;再看每一步是否有可优化的点,从数据结构与算法的角度考虑。
  2. 查找优化,想hash table/hash map,但是要注意空间复杂度的提升。
  3. 考虑各种情况,也就是TDD中的先思考测试用例,从最简单的一个下手,可能没有时间去重构,因此需要纵观测试用例,直接考虑普适情况。
  4. 解决链表问题时考虑只有一个元素及head被移除的情况,通常需要添加哨兵
  5. 使用栈的peek或pop操作时,需要保证栈非空。
  6. 循环链表时,最好不要以p.next是否为空作为终止条件,因为p可能为空。
  7. 做这种原地操作时,一定要注意先保存原链表指针的next,再操作。
  8. 快慢指针判断环是很巧妙的思路。
  9. 涉及多个指针的,先在纸上画,画完再写程序。
  10. 涉及多个指针的,要注意元素个数对其的影响。
  11. 有数据搬运操作时,注意分析不同搬运时刻所需的代价。
  12. 特别注意空指针问题。
  13. 最终字符串取决于后面字符时,考虑倒序遍历。
  14. 快慢指针循环条件:奇数个节点,快指针的next不为空;偶数个节点,快指针不为空。
  15. 从字符串中读取数字要注意数字位数。
  16. 不要陷入思维定式,要注意当前问题。
  17. 将迭代改为递归时,想数据作用域要求清零的时刻,有时需要增加变量;递归改为迭代时在数据作用域清零的时刻手动用栈模拟。
  18. 有时候可以通过排序结合一些约束避免重复。
  19. 测试用例要考虑全面,比如多个0对于上述算法的影响。
  20. 存在局部遍历(分块遍历)时,可以考虑while+多个指针以不同步调来回移动的方式。

leetcode-practice's People

Contributors

liukaixinhappy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.