Coder Social home page Coder Social logo

algorithm-leetcode's Introduction

视频:

归纳总结:

leetcode: leedcode讨论区代码:https://leetcode.com/problems/replace-the-substring-for-balanced-string/discuss/408978/javacpython-sliding-window/367697

github: starred 各种总结

3.Union Find 并查集
并查集:一种用来解决集合查询合并的数据结构 支持O(1)find/O(1)union
考点:
并查集原生操作:
查询两个元素是否在同一个集合内 find 操作
合并两个元素所在的集合 union 操作
并查集的派生操作:
查询某个元素所在集合的元素个数
查询当前集合的个数

4.Trie 字典树
考点
Trie直接实现
利用Trie树前缀特性解题
矩阵类字符串一个一个字符深度遍历的问题(DFS + Trie)

5.Heap 求集合的最大值

6.Stack
支持操作:O(1) Push / O(1) Pop / O(1) Top
规律
利用栈暂且保存有效信息
翻转栈的运用
栈优化dfs,变成非递归
单调栈:Monotonous stack 找每个元素左边或者右边 第一个比它自身小/大的元素 用单调栈来维护

7.二分法深入 找满足某个条件最大值/最小值:二分性 二分法——二分答案:Binary Search on Result.往往没有给你一个数组让你二分,同样是找到满足某个条件的最大或者最小值 解题方法:通过猜值判断是否满足题意不对去搜索可能解 1.找到可行解范围 2.猜答案 3.检验条件 4.调整搜索范围

8.扫描线 Sweep-Line 扫描问题的思路: 1.事件往往是以区间的形式存在 2.区间两端代表事件的开始和结束 3.需要排序 • 见到区间需要排序就可以考虑扫描线

0391.Number_of_Airplanes_in_the_Sky.py 扫描线做法:碰到interval的start,也就是起飞一架飞机,当前天上的飞机数++。碰到interval的end,也就是降落一架飞机,当前天上的飞机数--。 Step 1: 我们分别把所有的start和所有的end放进两个数组,并排序。Step 2: 然后从第一个start开始统计,碰到start较小就加一,碰到end较小就减一。并且同时维护一个最大飞机数的max。

线性数据结构:queue stack deque O(n) stack(monostack) queue deque

9.双端队列 deque • 只用掌握sliding windows maximum这一道题目 • 维护一个候选可能的最大值集合 0239.Sliding_Window_Maximum.py heapq的方法是O(NK); deque O(N): Iterate over the array. At each step: I. Clean the deque: 1. Keep only the indexes of elements from the current sliding window; 2. Remove indexes of all elements smaller than the current one, since they will not be the maximum ones. eg: [1,2,7,3,5,4], k = 3, because of 7, 1 and 2 will never be in res; II. Append the current element to the deque. Append deque[0] to the output.

10.动态规划滚动数组
滚动数组

记忆化搜索,当思路是从大的往小的推的时候,用记忆化搜索.当思路从小往大的推就用普通的for循环,从小往大计算。

没有任何思路的时候:DFS能做人任何题

algorithm-leetcode's People

Contributors

ling67 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.