摘要: 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 西施豆腐渣 阅读(128) 评论(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 西施豆腐渣 阅读(169) 评论(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 西施豆腐渣 阅读(120) 评论(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) 编辑