08 May 2020 | Leetcode May: Catch up! (1 through 8) Plus Cards
I had a day filled with coding. I did eight leetcoding challenges for the May challenge (which I didn’t know existed until today), and started on the binary search card. Every single one of these is ranked Easy.
This one I thought was really interesting because it says you can’t brute force it, but it let me brute force it. This is why I decided to do the Binary Search card. Apparently, the challenge is supposed to fail you for brute forcing, and only approve binary searches - but I’m guessing Go is fast enough to where it couldn’t detect that I just brute forced it :)
From all the binary work I’ve done in college, I would have figured this would be simple. You’re just shifting the bits, how hard could it be? Well, it’s not extremely challenging, but it took some research into the bits package. Note: This can also be done without the bits package, but it’s not as clean.
I absolutely lost it during this problem. This really should not be difficult, but Go refused to provide a float from integer division unless I casted literally every single element into a float64. I find this is one of the things that irritates me about using Go as compared to Java. I could really write an entire blog post at this point about things in Go that I’ve found that infuriate me. Among this would be lack of generics and the interface implementation.