LeetCode Getting Downright Ugly

I continue doing LeetCode exercises. Worked on another "Medium" difficulty problem today. Seemed straightforward enough. Find the longest length of any substring in a specified string that does not have any duplicated characters.

This is my practice for C++. Therefore I am using the STL to get more experience with it. Store all substrings in a vector. Write a function to determine if a string has any dup chars using a map. This works for most of the one thousand test cases. But there are a few where LeetCode says my solution took too long.

LOL wut? Some test cases pass in a massive amount of text. I am enumerating all combinations of substrings in there. After I tighten up my code, I guess that my dup detector is just taking too long. Therefore I get rid of the STL map from it. Code is up with straight C arrays. Works fine.

LeetCode Getting Tricky

I decided I would try to LeetCode exercises for practice. Nailed the first one I tried yesterday. It was an easy problem. The one I tried today was assessed as Medium difficulty. At first I thought the problem was easy. It passed the sample test case pretty quickly. Then I saw what the challenge was. They were testing you for huge numbers.

At first I tried to just change my variables from int to long. Nope. Not good enough. Then I tried long long int. Figured they might be testing up to that. Nope. They were dealing with huge numbers. I did not want to implement a big number library. Should not have been a need to copy and paste the code for such a library too.

Then it dawned on me. They were providing the input numbers in a weird linked list format that encouraged the use of big number addition. I did not need to implement the whole big number library. Just needed to be able to add two digits, and determine if there was any carry over to the next place.

These LeetCode problems are tricky. And I have not gotten to a Hard problem yet.

Practicing on LeetCode

I have been reading the Computer Science Careers subreddit recently. There is a lot of talk about how to prepare for job interviews. Many people mention doing problems on LeetCode. I have never heard of that site. I want to interview for another job. Maybe I should be doing practice problems on there too.

So I created an account. Seems like I could proceed without paying for a developer subscription. I went to problem number one. The site was preconfigured to use C++ as the programming language. Does the site just use that because it is a popular language? Or did it figure out I know C++ from my profile?

Had some trouble getting my first entry to compile. The error messages were a bit cryptic. No trouble. I know how to debug, isolating the faults. Got my code to return the correct result for the sample inputs. Then I submitted my solution.

Was a bit disappointed that, although my solution was accepted, 95% of the other solutions executed faster than mine. Nobody told me we would be graded on speed. Next time I will have to optimize my solution.