Tuesday, June 9, 2015

Leetcode: Convert Sorted List to Balanced Binary Search Tree (I) (No. 109)

Problem description: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
今天花了1个多小时, 调试这个程序;用C#代码, 没有搞明白; 读了几个博客; 非常苦恼.发现自己有时侯很沮丧,倒不如谦虚下来,看看算法的录像, 学点东西; 看代码, 看不明白.LeetCode有160多道题, 一道题搞半天, 一周才几道题.
先看了这个解法:
总之,非常喜欢这道题; 知道这道题考什么内容,直到读了这个网页. 今天尝试写了这个程序,用C#.知道想出这个最优方法不容易.
Write C# code based on the analysis of the above Leetcode solution.
https://github.com/jianminchen/Leetcode_C-/blob/master/109ConvertSortedListToBinarySearchTreeB.cs




No comments:

Post a Comment