摘要: 去Twitter面试的被问到这个问题,当时只想到了用HashMap的办法,这种办法时间复杂度O(n),空间复杂度是O(n), 更好的办法是用 FastRunner / SlowRunner approach。用两个pointer遍历链表,fast的速度是slow的两倍,如果有loop,二者一定会co... 阅读全文
posted @ 2014-07-15 05:45 门对夕阳 阅读(297) 评论(0) 推荐(0) 编辑
摘要: Partition an array of integers around a value such taht all elements less than x come before elements greater than or equal to x.Idea: Just use of sub... 阅读全文
posted @ 2014-07-15 01:53 门对夕阳 阅读(168) 评论(0) 推荐(0) 编辑