I got an invitation to Google FooBar!

I’ve been polishing my Java skills on https://codingbat.com/ for the past day when this black box appeared in my search result.

Fascinating! They gave me an invitation even when I cannot rattle off the methods inside Java’s ArrayList. Upon clicking the blue button, I was taken to this terminal-like webpage.

I took this screenshot after I finished the first challenge because I was too focused on solving it

I will not include the full question here because I am not sure if I’m allowed to. To summarize the first question, you are given an integer (0 to 1000000 inclusive), and you need to find a list of perfect squares that add up to the given integer, starting from the biggest one.

You can either write the solution in Java or Python (not sure which version). Upon receiving the question, a timer of 7 days was started and I need to submit the solution before that timer ends, but it only took me almost 3 hours to solve the it. Not bad for someone who does not do leetcode that much, eh?

First attempt. I forgot to include the namespaces lol
After including the namespaces.

At first, I thought some of the tests failed because they exceeded the time limit, but when I calculated the execution time, it did not even take that long. So I calculated the solution for i=0 until i=1000000 and saved the output to a text file for further inspection.

After reading the text file for a while, I noticed that whenever i is a perfect square, the function did not return that number itself as the solution (when it should). Then I realized I used the less than operator (<) when I should have used the less than or equal to (<=) operator in my solution.

The solutions generated after I fixed the code
All test cases passed after the small fix

We’ll see where this leads me 🙂 I hope I can at least secure an internship position if I managed to solve all the challenges

4 thoughts on “I got an invitation to Google FooBar!

  1. hello aiman, i once saw your github about toyyibpay unofficial v1. I’m kind newbie to this php integrate with payment gateway. Do you know how to make a coding or how to integrate all the APIs using sandbox mode?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.