Coder Social home page Coder Social logo

leetcode's Introduction

leetcode

1、做数组类算法问题的时候,我们常常需要定义一个变量,明确该变量的定义,并且在书写整个逻辑的时候,要不停的维护住这个变量的意义: 使用定义的变量做数组的索引,给原数组地址空间赋值,从而创建一个“新数组”。好处是不需要批量移动数组的元素来删除数组中的元素,直接构造“新数组”。

2、对撞指针: 对撞指针(一个首指针,一个尾指针)是遍历数组(字符串)的一种方式,时间复杂度是O(n)。相比二重for循环遍历数组的时间复杂度O(n²),对撞指针效率很高。

3、当 用一个指针便利一个数组(链表)时,如果当前位置的元素被交换(或者被删除后,用后面的元素置换),那么指针就不能继续向前走,需要继续处理被置换后的元素。 例如:“移除重复节点”、“颜色分类”。 但是遍历指针(遍历链表时)如果不向前走,可能会导致无法走出循环,而停在那里不动。

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.