摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.Solution:N-Queens 问题的简化版。pu... 阅读全文
posted @ 2014-10-18 07:22 Phoebe815 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2014-10-18 07:10 Phoebe815 阅读(161) 评论(0) 推荐(0) 编辑
摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2014-10-17 15:19 Phoebe815 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?Sol... 阅读全文
posted @ 2014-10-17 15:01 Phoebe815 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Solution:快慢指针。 1 /** 2 * Definition for s... 阅读全文
posted @ 2014-10-17 14:20 Phoebe815 阅读(94) 评论(0) 推荐(0) 编辑
摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文
posted @ 2014-10-17 14:10 Phoebe815 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2014-10-16 15:25 Phoebe815 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Say 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 a... 阅读全文
posted @ 2014-10-16 13:56 Phoebe815 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Say 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 a... 阅读全文
posted @ 2014-10-16 12:52 Phoebe815 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文
posted @ 2014-10-16 06:30 Phoebe815 阅读(128) 评论(0) 推荐(0) 编辑