Skip to content

Commit

Permalink
check if it is doubly linked list
Browse files Browse the repository at this point in the history
  • Loading branch information
WaderManasi committed Sep 16, 2020
1 parent dd9ac13 commit 7ea32ae
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Tricky_Problems/CheckDoublyll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//Given a doubly linked list, the task is to check if it is circular or not.

bool isCircular(Node * head)
{
if(head==NULL) return false;
Node* temp=head;
Node* p=head->prev;
while(temp->next!=head && temp->next!=NULL)
{
temp=temp->next;
}
return temp->next==head && temp==p?true:false;

}

0 comments on commit 7ea32ae

Please sign in to comment.