Category Archives: Uncategorized

  1. 记一下

    Leave a comment

    May 23, 2018 by oneOokay

    脸书店面: decode string LC 394. 印度人. 我紧张. 模糊的想到可以用stack,但是没有好好想好思路就开始写,没写通.写到一半换DFS(大忌). 面试官问, 你为什么觉得用DFS比用stack好呢…没get到这个hint, 继续跟DFS嗑. 还问能不能在纸上画…最后没时间了依旧没写出来,说了一下还是应该用stack做, 面试官说stack是对的.囧. 电话挂了之后5分钟写出来了.嚎啕大哭=.= 优步店面: 给你两个list of intervals, find there …
    Continue reading

  2. Reservoir Sampling solution

    Leave a comment

    February 7, 2018 by oneOokay

    Random Pick Index

  3. 线段树???

    Leave a comment

    February 5, 2018 by oneOokay

    Number of Longest Increasing Subsequence

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

  5. Read Characters From File – multiple calls

    Leave a comment

    January 17, 2018 by oneOokay

    The API: int read4(char *buf) reads 4characters at a time from a file. The return value is the actual number of characters read. …
    Continue reading

  6. Words Abbreviation

    Leave a comment

    January 14, 2018 by oneOokay

    Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below. Begin …
    Continue reading

  7. Kadane’s algorithm

    Leave a comment

    October 23, 2017 by oneOokay

    求一个array中的continuous subarray的sum的最大值. 其实是一个dp的想法.对于当前的array[i]有两种操作: 把它和之前的以array[i-1]为最后一个元素的subarray组合一起成一个新的subarray 以array[i]自己一个人的成一个新的subarray int[] dp : length == array.length. dp[i]表示以array[i]为最后一个元素的一个continuous array的max sum. 递推公式是: dp[i] = dp[i – 1] …
    Continue reading