Tag Archives: Stack

  1. System Longest File Path

    Leave a comment

    January 17, 2018 by oneOokay

    如何标记level? 用原本的\t\t\t?不.应该用数字来标记. 怎么算level数? \t的个数. ‘\t’和’\n’是1个字符,不是2个. 怎么读入String? 指针从左到右遍历读吗?太麻烦. 用str.split()把它分成String array,按顺序读入即可 注意计算length要每个层+1 (‘/’),最后一层不用. 思路1: 一个Stack放层数:1,2,3 一个ArrayList:对应的index表明该level的当前的StringLength 读入一个String, replace \t 得到一个新的string,把它与旧string相减即得当前string的level. 与stack peek的level相比,如果stack …
    Continue reading

  2. Remove K Digits

    Leave a comment

    June 25, 2017 by oneOokay

    Given a non-negative integer num represented as a string, remove k digits from the number so that the new number …
    Continue reading

  3. Next Greater Element II

    Leave a comment

    June 21, 2017 by oneOokay

    Given a circular array (the next element of the last element is the first element of the array), print the …
    Continue reading

  4. 三个点的位置.Graham scan.Convex Hull

    Leave a comment

    June 18, 2017 by oneOokay

    解决的是几何问题… 两条直线是否相交 二维数组标示x,y的点的集合, Find simple closed path. 就是点集外檐的一个轮廓.(connect the dots without crossing) 同样点的集合,求形成一个凸包的边缘点的集合. Orientation of 3 ordered points http://www.geeksforgeeks.org/orientation-3-ordered-points/ 给3个点,判断这三个点的相对位置. …
    Continue reading

  5. Validate Binary Search Tree

    Leave a comment

    November 30, 2016 by oneOokay

    Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as …
    Continue reading

  6. Min Stack

    Leave a comment

    November 20, 2016 by oneOokay

    Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) — Push element …
    Continue reading

  7. Using Inorder traversal in BST

    Leave a comment

    November 6, 2016 by oneOokay

    Inorder traversal: Recursive & 分治 可以用Inorder traversal来解决以下这两个问题: Kth Smallest Element in a BST In-order Iterative In-order Recursive DFS Validate Binary …
    Continue reading