C
C#14mo ago
Str1ke

❔ I made a function to check that there is no Same last variable in two queues in the queue array

Can you please check if I made it right, because I had to assign last and secondlast in order for it to not have errors
No description
2 Replies
Str1ke
Str1keOP14mo ago
public static bool NoSameLast(Queue<int>[] arr) { Queue<int> queue = new Queue<int>(); for (int i = 0; i < arr.Length; i++) { int last= 2; int secondlast= -2; while (!arr[i].IsEmpty()) { int x = arr[i].Remove(); queue.Insert(x); last = x; } while (!queue.IsEmpty()) { arr[i].Insert(queue.Remove()); } for (int x = i+1; x < arr.Length;i++) { while (!arr[x].IsEmpty()) { int y = arr[x].Remove(); queue.Insert(y); secondlast = y; } while (!queue.IsEmpty()) { arr[x].Insert(queue.Remove()); } if (last == secondlast) { return false; } } } return true; }
Accord
Accord14mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server