This is a simple code that would involves solving of two different problems based on the methods as shown below. This is a simple problem solving and therefore everything is done in the Program
class.
Problem: Given an array of list, sort it in such a way that the highest number is at the top, the second highest at the bottom, third highest is at the second position, fourth highest at second last position and so on. This makes the smallest number come in the middle.
Solution: The method SortArrayWithSmallestInMiddle
, takes in the array sorts it and only traverses through it once thus making complexity O(n).
Problem: Given an array list, find out how many numbers are duplicate and what numbers are those. Performance is the big part of it so it must be efficient.
Solution: The method FindDuplicate
uses dictionary (mainly hash) to find the numbers that are duplicate thus going through the array only once.