BrainTrain
A set of exercises to maintain healthy coding skills.
Exercise Available
-
MyHashTable A dummy hash table not intended to replace a dictionary ;)
-
MyStringBuilder A dummy string builder handling just string appending.
-
Exercise 1. Returns the smallest positive integer that does not occur in an array Write a function:
class Solution { public int solution(int[] A); }
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3], the function should return 1. Write an efficient algorithm for the following assumptions: N is an integer within the range [1..100,000]; each element of array A is an integer within the range [−1,000,000..1,000,000].
Usefull links
How to create a hash table from scratch in python https://coderbook.com/@marcus/how-to-create-a-hash-table-from-scratch-in-python
A string builder in Python https://gist.github.com/MohamedHajr/d7cee6a9aeaf01e0d7915eb44f7d8e6d