Git Product home page Git Product logo

leetcodesolution's Introduction

LeetCodeSolution

This is the solutions set of the LeetCode Website's problems.

Some Information

Notes

  • Climbing Stairs
    • 一开始用传统的递归解题,结果TL了。看了下Dscuss,搜索了一下,发现这道居然就是典型的动态规划题,用哈希把子问题的答案记录了就能节省大量的运行时间。
  • Linked List Cycle
    • 判断链表是否有环。通过快慢节点可以简单实现。
  • Unique Binary Search Trees
    • 本题参考了 http://cs.lmu.edu/~ray/notes/binarytrees/ 里面的*How Many Binary Trees Are There?*章节。
    • The first few terms:
      • C(0) = 1
      • C(1) = C(0)C(0) = 1
      • C(2) = C(0)C(1) + C(1)C(0) = 2
      • C(3) = C(0)C(2) + C(1)C(1) + C(2)C(0) = 5
      • C(4) = C(0)C(3) + C(1)C(2) + C(2)C(1) + C(3)C(0) = 14
    • 基本思路跟爬楼梯的题目一样。递归并记录之前求解的结果。
  • Populating Next Right Pointers in Each Node
    • 一开始的解题思路是分层遍历连接next,后面觉得这方法无论是空间还是时间都是一个问题。其实真正的难点无非在5->6这里,只需判断root.next != null 就差不多了。

leetcodesolution's People

Contributors

onewater avatar

Stargazers

 avatar

Watchers

James Cloos 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.