上一页 1 2 3 4 5 6 7 8 9 10 ··· 14 下一页
摘要: 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) 编辑
摘要: Same TreeSep 3 '12Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.bad one recursive./** * Definition for binary tree * public class TreeNode { * int val; * ... 阅读全文
posted @ 2013-01-30 17:05 西施豆腐渣 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Count and SayMar 6 '12The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"two 1s"or21.21is read off as"one 2, thenone 1"or1211.Given an integern, generate thenthsequence. 阅读全文
posted @ 2013-01-30 15:51 西施豆腐渣 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Inorder TraversalAug 27 '12Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[1,3,2].Note:Recursive solution is trivial, could you do it iteratively?confused what"{1,#,2,3}"means?> read more o 阅读全文
posted @ 2013-01-29 13:28 西施豆腐渣 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Best Time to Buy and Sell Stock IIINov 7 '12Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwotransactions.Note:You may not engage in multiple transactions at the same time (ie, you must 阅读全文
posted @ 2013-01-29 08:53 西施豆腐渣 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Best Time to Buy and Sell Stock IIOct 31 '12Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, 阅读全文
posted @ 2013-01-29 06:15 西施豆腐渣 阅读(152) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 14 下一页