Lexi's Leetcode solutions

[summery] Linked list题的要点

Posted on: August 9, 2013

  • generic list题的test cases
    1. normal case
    2. 1个ele
    3. 整个是个loop
    4. partial loop
  • 有可能删了元素的题:
    1. 小心head是不是被删了,要不要换新的
    2. prev指针一定要有,直接用一个指针指前一个,但是想删/动下一个,相比写p, p.next != null什么的,最好再keep一个prev指针,不容易乱套。即使多了一个var,总比写不对强!!
    3. 一般是Node head, Node prev, Node i, Node j四个指针。一定要写代码之前弄明白i, j都是什么物理意义!

Advertisements
Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: