上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页
摘要: Permutation SequenceMar 28 '12The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, forn= 3):"123""132""213""231""312""321"Givennandk, ret 阅读全文
posted @ 2013-02-14 16:02 西施豆腐渣 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Longest Palindromic SubstringNov 11 '11Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest palindromic substring.public class Solution { public String longestPalindrome(String s) { // Start ty... 阅读全文
posted @ 2013-02-14 09:32 西施豆腐渣 阅读(132) 评论(0) 推荐(0) 编辑
摘要: N-QueensMar 20 '12Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinct solutions to then-queens puzzle.Each solution contains a distinct board configuration of then-queens' placement, whe 阅读全文
posted @ 2013-02-14 07:52 西施豆腐渣 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Substring with Concatenation of All WordsFeb 24 '12You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters.For example, given:S:& 阅读全文
posted @ 2013-02-13 05:14 西施豆腐渣 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Rotate ListMar 28 '12Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL./** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * Lis 阅读全文
posted @ 2013-02-11 11:19 西施豆腐渣 阅读(254) 评论(0) 推荐(0) 编辑
摘要: Apr 18 '12Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]public class Solution { public ArrayList<ArrayList<Integer>> combine(int n, int k) { // Start ty... 阅读全文
posted @ 2013-02-10 05:38 西施豆腐渣 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Write a program that prints all the sub string that is palindrome within a input String. For e.g For input String "abbcacbca" output should be: [cac, bcacb, cbc, acbca, bb]URL: question?id=9689276package careercup; import java.util.ArrayList; import java.util.Arrays; import java.util.Linke 阅读全文
posted @ 2013-02-08 15:57 西施豆腐渣 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given a target value and a list of numbers to pick from, pick numbers from the list such that thenumbers picked add up to the target value.package careercup;import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List;public class test1 { private int target 阅读全文
posted @ 2013-02-07 07:19 西施豆腐渣 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Interleaving StringAug 31 '12Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="aadbbbaccc", return false..public class Solution { public boolean isInterleav 阅读全文
posted @ 2013-02-05 08:29 西施豆腐渣 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Rotate ImageMar 18 '12You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?public class Solution { public void rotate(int[][] matrix) { // Start typing your Java solution below // DO NOT write main() fu... 阅读全文
posted @ 2013-02-05 07:05 西施豆腐渣 阅读(135) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 14 下一页