Giter VIP home page Giter VIP logo

my_ltcd_slt's Introduction

my_ltcd_slt

my leetcode solution 2021 Aug 27th https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/description/ #有必要自己去看一下range的用法 #python的长度是len() #you时候 两个东西一个前移动 一个不移动 移动的那个for函数就已经帮实现了 不用在else里面写 #核心方法是使用快慢指针 https://leetcode-cn.com/problems/roman-to-integer/ Screen Shot 2021-08-28 at 12 42 16 AM

2021 Aug 31th so the key thing about memorization in dynamic programming is that we need to follow the following steps

  1. make it work // this step is the hard part visualize the problem as a tree implement the tree using recursion base case (memorization) not necessary in this step

    test it

  2. make it efficient // this step is much easy add a memo object add a base case to return memo value store return value into the memo object

2021 September 22th Tabulation recipe

visualize the problem as a table

size the table based on the input

initiate the table with default value

seed the trival answer into the table

iterate through the table

fill further positions based on the current position

二分查找重点概括 写成 while(left < right) ,退出循环的时候有 left == right 成立,好处是:不用判断应该返回 left 还是 right; 区间 [left..right] 划分只有以下两种情况: 分成 [left..mid] 和 [mid + 1..right],分别对应 right = mid 和 left = mid + 1; 分成 [left..mid - 1] 和 [mid..right],分别对应 right = mid - 1 和 left = mid,这种情况下。需要将 int mid = (left + right) / 2 改成 int mid = (left + right + 1) / 2,否则会出现死循环,这一点不用记,出现死循环的时候,把 left 和 right 的值打印出来看一下就很清楚了; 退出循环 left == right,如果可以确定区间 [left..right] 一定有解,直接返回 left 就可以,否则还需要对 left 这个位置单独做一次判断; 始终保持不变的是:在区间 [left..right] 里查找目标元素。

作者:liweiwei1419 链接:https://leetcode-cn.com/problems/search-insert-position/solution/te-bie-hao-yong-de-er-fen-cha-fa-fa-mo-ban-python-/ 来源:力扣(LeetCode) 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

hahaha

my_ltcd_slt's People

Stargazers

 avatar  avatar Hongyu Wan avatar Catherine Zeng avatar  avatar  avatar Bin avatar  avatar Zheng Yin (Yune) avatar

Watchers

Zheng Yin (Yune) avatar

Forkers

changthecoder

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.