摘要: 这道题比I难多了。由于是所有答案,肯定是全搜索。只能递归,虽然感觉效率很低,但似乎是唯一的办法,果然最后看到的测试用例也只有9个,再多估计就全超时了。public class Solution { public ArrayList generateTrees(int n) { return generateTrees(1, n); } private ArrayList generateTrees(int left, int right) { ArrayList ans = new ArrayList(); if (le... 阅读全文
posted @ 2013-10-06 22:09 阿牧遥 阅读(724) 评论(5) 推荐(1)