nice solution appreciate it. but your algorithm is wasting time in finding
all the element...
instead of that just find boundary line kth element which can help as in
finding element greater that kth and element small than kth and that soluton
can be done in O(N)
On Sun, Mar 28, 2010 at 10:02 PM,
@Umer: Its a singly LL and it has cycle. Both N1 and N2 will keep traversing
within the cycle.
On Sun, Mar 28, 2010 at 9:56 PM, Umer Farooq the.um...@gmail.com wrote:
I'll appreciate comments on the solution proposed by me. It works the
following way:
take two pointers, N1 and N2 pointing
that's why i have a terminating condition. It will keep on iterating until
((N2 != head)(N2-NextPtr != head)) is true.
head pointer of the linked list will be passed as an argument to the
function.
On Mon, Mar 29, 2010 at 7:04 AM, Navin Naidu navinmna...@gmail.com wrote:
@Umer: Its a singly LL
@Umer: I guess the last node in the LL is _not_ pointing to the head
back. Rather, its pointing to one of the intermediate nodes. That way,
N2 or N2.next might not ever be _head_. See example: 1-2-3-4-5-3,
where the last node points to the 3rd node in LL.
On Mar 29, 9:21 pm, Umer Farooq
that will result into an infinite loop,
On Mon, Mar 29, 2010 at 9:51 PM, Umer Farooq the.um...@gmail.com wrote:
that's why i have a terminating condition. It will keep on iterating until
((N2 != head)(N2-NextPtr != head)) is true.
head pointer of the linked list will be passed as an
@Umer Farooq
but cycle can be between the nodes(not like circular list) so we may not get
head node.
@all
i think mukesh answer is right
On Mon, Mar 29, 2010 at 9:21 AM, Umer Farooq the.um...@gmail.com wrote:
that's why i have a terminating condition. It will keep on iterating until
((N2 !=