原创 面試題中的二叉樹根據和尋路徑問題

二叉樹是面試裏常考的一類數據結構,其中有一類尋找路徑問題很有意思。目前見過兩種類型題目,都是先給出一個和,然後要求打印出節點值之和與此相等的路徑問題。 1. Given a binary tree and a number, print

原创 有趣的Google面試題 - Harry Potter走矩陣

MITBBS上看了一道有趣的G家面試題,題目如下: 有一個2維矩陣,假設你是Harry Potter,在矩陣的左上角,你現在要走到右下角。矩陣中每個點都有一個權值,有正數也有負數,遇到正數表示你的生命力能增加那麼多,遇到負數表示生命力減少

原创 使用PuTTY時對原始設置的幾個簡單實用修改

由於經常需要在cluster上進行編程,所以自己常常需要使用PuTTY。(當然你也可以選擇X-Win32,不過個人覺得圖形界面對於日常編程來說基本沒什麼用,否則會找個Linux系統在ssh的時候加上-Y以支持圖形界面。) 下面總結幾條對

原创 春假扭腰Bloomberg一遊

春假去了趟扭腰參觀了下Bloomberg,發現總部在Mahattan這種寸土寸金的地段還挺大的,裏面裝修也還不錯。最重要的是,放眼望去,男女比例還是不錯的,比一般的IT公司還是要均衡很多,至少給我面試的人裏面都是男女成對出現,雖然不知道這

原创 [LeetCode] Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any s

原创 [LeetCode] Sort List

Sort a linked list in O(n log n) time using constant space complexity. 這題思路比較直接。按照題目要求,需要在O(N*logN)時間內完成排序,所以可以考慮的排序方法

原创 [LeetCode] Word Ladder

Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to 

原创 總結排序(或部分排序)矩陣上的搜索問題

在排好序(或者部分排好序)的矩陣上進行搜索是考察多維數組操作和查找的一種經典面試題類型。這裏假設行數和列數分別是M和N。下面根據難度來總結一下幾個不同的題目變體: 1. LeetCode原題 Search a 2D Matrix:

原创 [LeetCode] Candy

There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these chil

原创 [LeetCode] Valid Number

Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" =>

原创 2014年1月7日Google實習電面

Google兩輪電面,兩個面試官都根據我的背景聊了下big data。第一輪相談甚歡,就問了我一個題目:給K個排好序的鏈表,總長度爲N,求如何合併成一個排好序的總鏈表。我先談了談直接設K個指針從每個表頭開始掃,每次將k個數中的最小數加入總

原创 [LeetCode] Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 這題之前想把任意兩點間都練成直線,這

原创 支持O(1)時間增加,刪除和隨機選擇操作的數據結構

最近看到一道經常出現的設計題:設計一個數據結構,對服務器Server類支持以下操作: 加入一個Server。 刪除一個Server。 隨機選擇一個Server。 以上所有操作的時間複雜度都必須爲O(1)。此題如果抽象出來,其實就是要求

原创 [LeetCode] Word Ladder II

Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, su

原创 [LeetCode] Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (le