When dealing with algorithms and data structures, people sometimes have a skewed perception of those being very complicated. Yet, in the majority of cases, they are pretty simple and intuitive. The only thing required to master those is some practice and hands-on experience to get the intuition of how the algorithms actually work.
When dealing with specific problems and exercises, it soon becomes clear that there are certain groups and categories of problems that can be viewed together. They share certain characteristics that make it possible to apply some techniques to the whole group of those problems.
One of those groups is the implementation problems. Those problems usually include the steps to get to the solution right in the problem statement. So, the actions the program needs to perform are described in the problem itself. The task of the software engineer becomes to implement those steps correctly and obtain the desired result. It’s important to note that even though the steps are described in the statement itself, it might not be straightforward to implement those right away.
Given all the numbers from 1 to
nexcept one, you are asked to find the missing number.
The first line of the input contains a single integer
n(2 ≤ n ≤ ).
The second line of the input contains
n-1space-separated integers (1 ≤ ≤ n).
The program should print the missing number.
4 3 4 1
3 2 1