August 23, 2020

Go Interview Question #3 - Write a function that checks if brackets are balanced

Another very common interview question, is to check if brackets are balanced in a string. If you have never done any stack questions before, this can be tricky. But, once you see how a stack can be used, it becomes very straightforward. Let’s look at what balanced brackets look like: “(())()”, “((()))”, “()”… Unbalanced brackets: “(((”, “())”, “(()”… A stack is like a can of Pringles, the last chip that was put into it, is the first to come out. Read more

May 16, 2020

Go Interview Question #2 - Write a function to check if a string is a palindrome

This question is very common on interviews, and while fairly straightforward, plenty developers mess it up on the interview. What is a palindrome? Webster dictionary defines it as a word, sentence or number that reads the same forwards and backwards. Some examples are: dad, 1881, abba. There are a few approaches to solving this problem, we can reverse the array of characters and compare the resulting string for example. The more efficient way of doing this is to compare the characters from the beginning and from the end one-by-one. Read more

May 6, 2020

Go Interview Question #1 - Find all the prime numbers less than or equal to 'n'

As a means of keeping my logic sharp and helping others prepare for Go interviews I decided to release a solved interview question every week or so. In this post, let’s write a function in Go that generates us all the primes at or below a specific integer. To even attempt this question, we need to know the exact definition of a prime number. According to Wolfram, A prime number is a positive integer p>1 that has no positive integer divisors other than 1 and p itself. Read more

© Ilya Nemtsev 2019

Powered by Hugo.