1.
Leaders in an Array ⭐⭐
A number is called a leader if it is greater than all elements to its right.
Input
Plain text
16 17 4 3 5
Output
Plain text
17 5
Explanation
17 is greater than all elements after it.
5 is the last element, so it is always a leader.
Concepts: Arrays + Nested Loops
2. Matrix Boundary Sum ⭐⭐⭐
Find the sum of only the boundary elements of a matrix.
Input
Plain text
33
123
456
789
Output
Plain text
40
Explanation
Boundary elements:
Plain text
123
4 6
789
Sum = 40
Concepts: Matrix + Conditions
3. Frequency of Every Element ⭐⭐⭐
Count how many times each element appears in an array.
Input
Plain text
1213214
Output
Plain text
1 -> 3
2 -> 2
3 -> 1
4 -> 1
Condition: Don't use HashMap.
Concepts: Arrays + Nested Loops + Boolean Logic
4. Automorphic Number ⭐⭐⭐
A number is automorphic if its square ends with the same digits as the
number.
Example
Plain text
5² = 25
Ends with 5 → Automorphic
Plain text
25² = 625
Ends with 25 → Automorphic
Input
Plain text
25
Output
Plain text
Automorphic Number
Concepts: Loops + Math Logic
5. Saddle Point in Matrix ⭐⭐⭐⭐
A saddle point is:
Smallest element in its row
Largest element in its column
Input
Plain text
33
123
456
789
Output
Plain text
Explanation
7 is the smallest in its row and largest in its column.
Concepts: Matrix + Multiple Traversals