上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页
摘要: AnagramsMar 19 '12Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.public class Solution { public ArrayList<String> anagrams(String[] strs) { // Start typing your Java solution below // DO NOT write main() function ... 阅读全文
posted @ 2013-01-28 21:50 西施豆腐渣 阅读(127) 评论(0) 推荐(0) 编辑
摘要: serialization and deserialization a binary tree.void buildtree(TreeNode* &p, ifstream& ifs){ string token; readNextToken(ifs, token); while(token==","){ readNextToken(ifs, token); } if(token=="#") {return;} TreeNode *tn = new TreeNode( atoi( token ) ); p = tn; buildtree(t 阅读全文
posted @ 2013-01-28 21:04 西施豆腐渣 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Add Two NumbersNov 1 '11You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.Input:(2 -> 4 -> 3) + (5 -> 6 -> 4)Output:7 -> 0 阅读全文
posted @ 2013-01-28 20:59 西施豆腐渣 阅读(119) 评论(0) 推荐(0) 编辑
摘要: Add BinaryApr 2 '12Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".public class Solution { public String addBinary(String a, String b) { // Start typing your Java solution below // DO NOT write main() function c 阅读全文
posted @ 2013-01-28 20:40 西施豆腐渣 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 3Sum ClosestJan 18 '12Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {-1 2 1 -4}, and target = 1. The... 阅读全文
posted @ 2013-01-27 14:06 西施豆腐渣 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Word SearchApr 18 '12Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.For 阅读全文
posted @ 2013-01-27 09:48 西施豆腐渣 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Valid PalindromeJan 13Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isnota palindrome.Note:Have you consider that the string might be empty? This 阅读全文
posted @ 2013-01-26 20:16 西施豆腐渣 阅读(138) 评论(0) 推荐(0) 编辑
摘要: String to Integer (atoi)Dec 27 '11Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.Notes:It is intended for this problem to be specified vaguely (ie 阅读全文
posted @ 2013-01-26 19:51 西施豆腐渣 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Sqrt(x)Apr 3 '12Implementint sqrt(int x).Compute and return the square root ofx.class Solution { public: int sqrt(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function // Start typing your Java solution below // DO NOT writ... 阅读全文
posted @ 2013-01-26 05:25 西施豆腐渣 阅读(131) 评论(0) 推荐(0) 编辑
摘要: find prime number within n;#include <iostream> #include <vector> #include <set> #include <cmath> using namespace std; bool isPrime(int n) { if( n==2) return true; int temp = (int)sqrt( (double)n); for( int i=2; i<temp; i++) { if( n%i==0) return false; } return true; } vect 阅读全文
posted @ 2013-01-25 06:37 西施豆腐渣 阅读(124) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页