Runtime Exercise 3: Designing algorithms and writing code

How would you solve the following problems? Can you think of an O(n^2), O(n log n), and O(n) solution to each problem? If you have time, code one of the functions you thought of to solve the problem.

Find the integer that occurs most frequently in an array

Examples:

Write a function that takes an array of numbers and returns the greatest difference you can get by subtracting any two of those numbers.

Examples:

Find the only element in an array that only occurs once

Examples:

Find the common elements of 2 integer arrays

Examples:

Determine if 2 Strings are anagrams (use the same letters re-arranged)

Examples:

Check if a String is composed of all unique characters

Examples:

Sources: