Whats good yall
Just a quick PSA for those just starting coding problems, so yall can avoid the mistakes I made when starting out
I was practicing some Codewars, when I saw this solution at the top.
Although it looks very flashy because its 3 lines, its actually terrible!
The right solution is BigO(n), but this solution is BigO(n^3)!! As indexOf and lastIndexOf both loop through the array.
The next "Best Practices" solution uses an obscure mechanic, a ^ bitwise operator ! Imagine how hard it is to debug a codebase full of this flashy programming😭😭😭
The "Best Practice" practically speaking, is a solution that is easy to read and understand, even if it requires more lines of code.
So don't feel down if you're solution isn't haiku-level brief! If it's readable and understandable, its good.
🫡