• + 0 comments

    This problem's C# definition of DoublyLinkedListNode and DoublyLinkedList are buggy.

    The way the author of this problem defined these classes in C# requires that the classes' fields (i.e., prev, next, head, tail) be set to a non-null values before exiting the constructor, and the classes' constructors aren't written to allow these parameters to be passed in.

    So it will always fail if you try to solve this problem in C#.

    Here's the full exception:

    /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(24,25): warning CS8625: Cannot convert null literal to non-nullable reference type. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(25,25): warning CS8625: Cannot convert null literal to non-nullable reference type. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(22,16): warning CS8618: Non-nullable field 'next' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(22,16): warning CS8618: Non-nullable field 'prev' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(34,25): warning CS8625: Cannot convert null literal to non-nullable reference type. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(35,25): warning CS8625: Cannot convert null literal to non-nullable reference type. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(33,16): warning CS8618: Non-nullable field 'head' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(33,16): warning CS8618: Non-nullable field 'tail' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(119,43): error CS0103: The name 'reverse' does not exist in the current context [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj] /tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.cs(105,50): warning CS8604: Possible null reference argument for parameter 'path' in 'StreamWriter.StreamWriter(string path, bool append)'. [/tmp/submission/20241104/05/55/hackerrank-71c387b303654a6e1a4f4f7510a502c7/code/Solution.csproj]