Leetcode
文章平均质量分 80
stongan
这个作者很懒,什么都没留下…
展开
-
【Leetcode】Reorder List
遇到问题:判断fast->next->next是否为空,需要先判断fast->next是否为空。题目:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes'原创 2015-04-29 10:29:33 · 258 阅读 · 0 评论 -
【Leetcode】Remove Duplicates from Sorted List II
问题:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Gi原创 2015-04-29 16:55:40 · 268 阅读 · 0 评论 -
【Leetcode】Surrounded Regions
很好的广度优先的题。刚开始思路采用最基本的思路,遍历棋盘进行搜索比较。此方式的需加visited[i][j]进行标识其是否访问过(可使用一维数组存储二维数组i*row+j来访问)。当此方式遍历时,只需要考虑右方和下方即可,因为是整个棋盘的遍历,所以不存在漏选的情况。=========此方式过不了大数据。。。思路(from net)既然已经知道连通区域必须至少一个元素是在四边原创 2015-06-01 15:49:50 · 341 阅读 · 0 评论