原文:leetcode 457. Circular Array Loop

先回顧一下鏈表的類似問題 leetcode 判定鏈表是否有環 慢指針slowPtr每次后移 個結點。快指針fastPtr每次后移 個結點 LeetCode 找出環的入口點 起點 當fast按照每次 步,slow每次一步的方式走,發現fastPtr和slowPtr重合,確定了單向鏈表有環路。接下來,讓slowPrt回到鏈表的頭部,然后slowPtr和fastPtr各自從自己的位置 fastPtr從兩 ...

2020-01-07 00:38 0 719 推薦指數:

查看詳情

[LeetCode] Merge Sorted Array

Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume that A has enough space to hold additional elements ...

Fri Nov 16 19:34:00 CST 2012 0 5297
[LeetCode 1146] Snapshot Array

mplement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given ...

Wed Aug 07 20:06:00 CST 2019 0 692
[leetcode]Rotate Array

in place交換 如果是k步,那么就是把后面k個放到前面了嘛。 我們先把整個數組reverse,然后把前面的reverse回來,再把后面的reverse回來 對於AB我們要通過reve ...

Fri Feb 27 05:03:00 CST 2015 0 2047
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM