摘要: 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) 编辑