O******i 发帖数: 269 | 1 Please implement the loop detection for std::list, like hasLoop(std::list
alist)
如果是普通链表找环,可以用两个指针,一快一慢。能套用到这题么?具体code如何写?
bool hasLoop(std::list alist)
{
blablabla
} |
y*******g 发帖数: 6599 | 2 iterator和指针一样用
写?
【在 O******i 的大作中提到】 : Please implement the loop detection for std::list, like hasLoop(std::list : alist) : 如果是普通链表找环,可以用两个指针,一快一慢。能套用到这题么?具体code如何写? : bool hasLoop(std::list alist) : { : blablabla : }
|
S**I 发帖数: 15689 | 3 How could you create a STL list containing a loop?
写?
【在 O******i 的大作中提到】 : Please implement the loop detection for std::list, like hasLoop(std::list : alist) : 如果是普通链表找环,可以用两个指针,一快一慢。能套用到这题么?具体code如何写? : bool hasLoop(std::list alist) : { : blablabla : }
|
q****x 发帖数: 7404 | 4 haha, good question.
【在 S**I 的大作中提到】 : How could you create a STL list containing a loop? : : 写?
|
f*******t 发帖数: 7549 | 5 re
【在 S**I 的大作中提到】 : How could you create a STL list containing a loop? : : 写?
|
y*******g 发帖数: 6599 | 6 正常的linked list也不会有loop
How could you create a STL list containing a loop?
写?
【在 S**I 的大作中提到】 : How could you create a STL list containing a loop? : : 写?
|
j********x 发帖数: 2330 | |
u**r 发帖数: 663 | 8 list的iterator能造出loop么?
stl的list里头iterator难道不是单调从list.begin()走到list.end()?
【在 y*******g 的大作中提到】 : iterator和指针一样用 : : 写?
|
H****s 发帖数: 247 | 9 std::list不能有loop而且std::list是doubly linked list, how could a doubly
linked list contains a cycle if the begin() is not equal to end()? |
y*******g 发帖数: 6599 | 10 好像按list的API是弄不出环,想错了
【在 u**r 的大作中提到】 : list的iterator能造出loop么? : stl的list里头iterator难道不是单调从list.begin()走到list.end()?
|
a****n 发帖数: 1887 | |