You’re making great progress! However, I noticed a few issues in your code that might cause unexpected behavior:
Issues in Your Code:
Sorting & Duplicates – Your function doesn’t sort the array or remove duplicates before checking for straights. This can lead to incorrect results if numbers are out of order or repeated.
Incorrect Sequence Checking – The way you’re comparing the number sequences directly as strings might not work correctly if the order isn’t consistent.
Redundant Conditions – You’re performing multiple checks that could be optimized, making the function cleaner and more efficient.
How to Fix It:
Sort the array to ensure numbers are in the correct order.
Remove duplicates so repeated numbers don’t interfere with the sequence check.
Use substring matching instead of direct comparison to detect valid straights more reliably.
You’re almost there! Try making these changes, and your function will work much better. Let me know if you need any help!