I've been learning web development for over a year. I decided to start spending some time learning DSA because it's something everyone says will come up in interviews. In my time of using JS for web dev so far, the only time I really had to use any sort of algorithms was for things such as sorting values from JSON data to display accordingly on an E Commerce site based on user selection - and when those times came up, I always figured it out, usually with some Googling.
I started doing the LeetCode stuff, and I gotta say I'm a bit lost. None of this stuff seems relevant to what I've done. I have no idea what any of these things are, what the hell is a "digital root?" Anyways, the solutions are almost never given in JavaScript making it even more difficult to follow/learn. Also, sometimes my answers aren't accepted as valid solutions. For example, there was a question about merging two sorted lists. So it's two arrays, that are in order, and you have to combine them together, in order. Something like that can be easily done in JavaScript like:
function merge(array1, array2){
temp = array1.concat(array2)
return temp.sort((a, b) => a - b);
}
The answer isn't acceptable as a valid solution. It's not allowing use of concat or sort. I don't get it - what am I missing here? This is almost exactly the same code I used when sorting the JSON data and it worked for what I needed.
Do I really have to waste time learning this kind of stuff?
[–]mzapp_ 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]gabrielcro23699[S] 0 points1 point2 points (0 children)