<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>next Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/next/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/next/</link>
	<description></description>
	<lastBuildDate>Thu, 08 Mar 2018 16:44:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>next Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/next/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 206. Reverse Linked List</title>
		<link>https://zxi.mytechroad.com/blog/list/leetcode-206-reverse-linked-list/</link>
					<comments>https://zxi.mytechroad.com/blog/list/leetcode-206-reverse-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Thu, 08 Mar 2018 16:44:14 +0000</pubDate>
				<category><![CDATA[List]]></category>
		<category><![CDATA[curr]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[next]]></category>
		<category><![CDATA[prev]]></category>
		<category><![CDATA[reverse]]></category>
		<guid isPermaLink="false">http://zxi.mytechroad.com/blog/?p=2044</guid>

					<description><![CDATA[<p>题目大意：反转一个单向链表 Problem: https://leetcode.com/problems/reverse-linked-list/description/ Reverse a singly linked list. Solution 1: Tracking prev / curr / next node Time complexity: O(n) Space complexity: O(1) C++ [crayon-663c9aa064845793140059/]&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/list/leetcode-206-reverse-linked-list/">花花酱 LeetCode 206. Reverse Linked List</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>题目大意：反转一个单向链表</p>
<p><strong>Problem:</strong></p>
<p><a href="https://leetcode.com/problems/reverse-linked-list/description/">https://leetcode.com/problems/reverse-linked-list/description/</a></p>
<p>Reverse a singly linked list.</p>
<p><strong>Solution 1:</strong></p>
<p>Tracking prev / curr / next node</p>
<p>Time complexity: O(n)</p>
<p>Space complexity: O(1)</p>
<p>C++</p><pre class="crayon-plain-tag">// Author: Huahua
// Running time: 9 ms
class Solution {
public:
  ListNode* reverseList(ListNode* head) {
    ListNode* prev = nullptr;
    ListNode* curr = head;
    ListNode* next;
    while (curr) {
      next = curr-&gt;next;
      curr-&gt;next = prev;
      prev = curr;
      curr = next;
    }
    return prev;
  }
};</pre><p>Java</p><pre class="crayon-plain-tag">// Author: Huahua
// Running time: 0 ms
class Solution {
  public ListNode reverseList(ListNode head) {
    ListNode prev = null;
    ListNode curr = head;
    ListNode next;
    while (curr != null) {
      next = curr.next;
      curr.next = prev;
      prev = curr;
      curr = next;
    }
    return prev;
  }
}</pre><p>Python 3</p><pre class="crayon-plain-tag">"""
Author: Huahua
Running time: 48 ms
"""
class Solution:
  def reverseList(self, head):
    prev, curr, nxt = None, head, None;    
    while curr:
      nxt, curr.next = curr.next, prev      
      prev, curr = curr, nxt
    return prev</pre><p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/list/leetcode-206-reverse-linked-list/">花花酱 LeetCode 206. Reverse Linked List</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/list/leetcode-206-reverse-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
