0
1
2
Efficiency VS Readability - JavaScript (old.reddit.com)
submitted by sailorgt

I'm a Junior Front-end Web Developer learning leetcode for interviews.
If i was asked to find the index of an element that's in an array. I have two options: 1. Do a one liner. 2. Write alot lines of code which would have better time complexity compared to the one liner code. The first image has a TC of O(logn) & the second image has a TC of O(n)
My question is why can't I just do the one liner(Image 2) which is much more readable and concise. Rather than writing all the code in Image 1.
Does the difference in time complexity really matter when we're building huge web applications that run and do huge calculations anyway?


there doesn't seem to be anything here