摘要: Given a binary tree, find the lowest common ancestor of two given nodes in the tree. _______3______ / \ ___5__ ___1__ / \ / \ 6 _2 0 8 / \ 7 4If you are not so sure about the definition of lowest com... 阅读全文
posted @ 2013-01-31 16:51 西施豆腐渣 阅读(192) 评论(0) 推荐(0) 编辑
摘要: First, ask yourself, what does the interviewer mean by an additional bu#er? Can we use anadditional array of constant size? Algorithm—No (Large) Additional Memory:1. For each character, check if it is a duplicate of already found characters.2. Skip duplicate characters and update the non duplicate c 阅读全文
posted @ 2013-01-31 11:38 西施豆腐渣 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Write code to reverse a C-Style String. (C-String means that “abcd” is represented as!ve characters, including the null character.)#include <iostream> #include <vector> #include <set> #include <cmath> #include <fstream> using namespace std; void main(int argc, char** ar 阅读全文
posted @ 2013-01-31 09:56 西施豆腐渣 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Implement an algorithm to determine if a string has all unique characters. What ifyou can not use additional data structures?package careercup; public class test1 { /*Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?*/ ... 阅读全文
posted @ 2013-01-31 08:26 西施豆腐渣 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Convert Sorted List to Binary Search TreeOct 3 '12Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.uncompleted/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) ... 阅读全文
posted @ 2013-01-31 06:52 西施豆腐渣 阅读(108) 评论(0) 推荐(0) 编辑