原创 [cc一百五]Unique char in String

Q1.1 Whether a string has all unique characters, if not use additional data structures? 首先畢竟重要的是要確定String是否是ASCII Strin

原创 [cc]18.9中位數

Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new va

原创 18.3shuffle cards

洗牌算法  寫一個隨機洗牌函數。要求洗出的52!種組合都是等概率的。 也就是你洗出的一種組合的概率是1/(52!)。假設已經給你一個完美的隨機數發生器。 問題:每次隨機取出一張牌,要注意已經取出的牌不會

原创 Find next node in bst

碰到過好幾次,interview常考高頻題,面寶石家的時候這道題當時跪的很徹底,在小哥各種題目下才勉強寫出來。 其實大意就是找inorder traversal 裏下一個,但是不需要得到所有inorder  結果 geeksforgeek

原创 [cc]17.10 print encoded version of an XML element

Question: 17.10 按照新的要求encode xml given a way of encoding XML where each tag gets mapped to a pre-defined integer value.

原创 Probability of passing exam by guessing

Q37: Probability of passing exam by guessing10 multiple choice (abcd 4 choices) questions , pass = at least 5/10 questi

原创 Coding Question

面過的幾家小公司,結果有好有壞,但是感覺自己基礎還是很差,要學習的東西真是還有很多,總結一下做的不好的題目 1 liveramp 分析時間複雜度題目: n 個數,任意兩個組成pair, 問所有pair再相加時間複雜度,題目明顯引導你選O

原创 17.9設計一個函數,找到給定單詞在一本書中的出現次數

cc 17.9 hashtable應用 首先需要考慮這個函數被調用的次數,如果只查詢一次,直接遍歷整本書,計算給定單詞次數。時間只能是O(N)。 正常情況下通常需要可以多次調用 這樣pre-processing the book,use

原创 Binary Tree & BST

1 二叉樹: 比較特殊的一種遍歷 Euler tour: a walk around the binary tree where each edge is treated as a wall, which you cannot cross

原创 Path Sum

最開始覺得很簡單dfs的題,但是再做的時候才發現第一次做的時候很多問題並沒有想清楚想明白結合面經把這道題重新做一遍。 1 Path Sum from root to leaf leetcode原題 pathsumii Given a

原创 LinkedList

LinkedList  easy to expend, such as insert or delete each element is a separate object : Node disadvantage: need more m

原创 Remove duplicate 問題

leetcode上有四道題,主要是remove from linked list和array 都是two pointer解決,要注意終止條件,還有移動指針時條件 3 Remove from sorted list Given 1->1

原创 CC150 OOD Parking Lot

Design a parking lot using object- oriented principles https://github.com/gaylemcd/ctci/tree/master/java/Chapter%208/Qu

原创 Top K frequency 系列

似乎這類問題還是滿經常被遇到的,一直不是特別會,決定把這類問題做一個總結,如果遇到新的時時更新加進來 idea: 通常hashmap<key, value> 來記錄< obj, count> 統計頻率 然後minheap(priority

原创 Lexicographically minimum string rotation

http://geeksquiz.com/lexicographically-minimum-string-rotation/ lexicographically字典序,在文本分析和搜索中有不少應用,比如在查詢語句的預處理時,可以通過求得