I am tired of being rubbish at technical interviews. I realized that the only way that I can stop being rubbish at technical interviews is to develop a better understanding of data structures, develop a more friendly relationship with algorithms, and practice.
Problem Statement Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without extra memory? Thought Process My initial conclusion was that no, you couldn’t. Since there’s not a range for the possible numbers in the array and the array isn’t already sorted, you can solve in linear time if you used an object to store counts, but you need that extra storage or sorting is O(n log n).
Problem Statement: Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array elements between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array.
For this second installment of Getting Going With Go, we’re going to cover
slices – how to create them, how to add more elements to them, and how to retrieve the elements of them individually. We’ll also cover how what
maps are in Go and how to create them.