© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
1 reply
lia

Queue and Node question

public static bool EqualSums(Queue<int> q)
{
int first = q.Remove();
int last = RemoveLast(q);
int sum = first + last;
Queue<int> c = q;
for(int i = 0; i < Length(q)/2; i++)
{
if(q.Remove() + RemoveLast(q) != sum)
{
return false;
}
}
if(!q.IsEmpty() && q.Remove() != sum) { return false; }
return true;
}

public static void RemoveEqualSums(Node<Queue<int>> lst)
{
Node<Queue<int>> curr = lst;
if (EqualSums(curr.GetValue()) == false)
{
curr.SetNext(null);
}
while (curr.GetNext() != null)
{
if(EqualSums(curr.GetNext().GetValue()) ==false)
{
curr.SetNext(curr.GetNext().GetNext());
curr.GetNext().SetNext(null);
}
curr = curr.GetNext();

}

} why is this code incorrect? please help
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

socket message queue questions
C#CC# / help
3y ago
Priority queue, queue empty error.
C#CC# / help
2y ago
❔ QuestionController
C#CC# / help
3y ago
Queue Cancellationtoken
C#CC# / help
2y ago