Created
February 22, 2022 14:24
-
-
Save eduuh/7f0d7e1acadb1120abc98b7be81302d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Algorithms { | |
class CustomLinkedList { | |
Node head; | |
public class Node { | |
public int data; | |
public Node next; | |
public Node(int d) | |
{ | |
data = d; | |
next = null; | |
} | |
} | |
public Boolean hasCycle() { | |
return false; | |
} | |
static void Main(string[] args) { | |
CustomLinkedList noCycleLinkedList = new CustomLinkedList(); | |
Node firstNode = new Node(3); | |
Node secondNode = new Node(4); | |
Node thirdNode = new Node(5); | |
Node fourthNode = new Node(6); | |
noCycleLinkedList.head = firstNode; | |
firstNode.next = secondNode; | |
secondNode.next = thirdNode; | |
thirdNode.next = fourthNode; | |
Console.WriteLine(noCycleLinkedList.hasCycle()); | |
CustomLinkedList cycleLinkedList = new CustomLinkedList(); | |
cycleLinkedList.head = firstNode; | |
thirdNode.next = secondNode; | |
Console.WriteLine(cycleLinkedList.hasCycle()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment