Giter Site home page Giter Site logo

exercise-book's Introduction

算法的练习本

一期工程为 左程云 程序员代码面试指南

leetcode每日一题

Java基本语法相关

栈和队列

  • 初始化方式及API选择
      Stack<Integer> s = new Stack<>();
      
      LinkedList<Integer> s = new LinkedList<>(); //stack也可作为Linkedlist初始化
      
      Queue<PetEnterQueue> q = new LinkedList();
  • Stack类API:
      s.pop()
      s.push()
      s.peek()
      s.isempty()
  • LinkedList类的API:
     s.add()
     s.addAll(Collection c)
     s.clear()
     s.contains()
     s.get(index)
     s.indexOf(Object o)  

数组

  • 遍历操作(也不是特别好用)
   forint i : arr){
   }

算法相关

Indexed Tree

Tree with pre and suf pointer. Inorder Traverse a tree by making it an indexed tree.

// non-iterative
public List<Integer> inorderTraversal(TreeNode root){
  List<Integer> res = new ArrayList<>();
  Deque<TreeNode> stack = new ArrayDeque<>();
  TreeNode cur = root;
  while(cur != null){
    if(cur.left == null){
      res.add(cur.val);
      cur = cur.right;
      }else{
        pre = cur.left;
      }
      pre.right = cur;
      TreeNode tmp = cur;
      cur = cur.left;
      tmp.left = null;
      }
   }
   return res;
}

Python基本语法相关

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.