Write a function that takes an array of positive integers and returns the second largest element.
Implement a function to rotate an array k times to the right.
Example: [1, 2, 3, 4, 5] rotated by 2 → [4, 5, 1, 2, 3].
Given two sorted arrays, merge them into a single sorted array.
Print a given N × M matrix in spiral order, clockwise from the top-left challenge question
Sample input:
N = 4, M = 4
matrix = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15, 16}
}
Sample output:
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
Given an unsorted array of integers and an integer k, write a function to print the k largest elements in the array. You may only use a queue, a stack, or a priority queue (or a combination) to solve this problem, do not create any other data structures. Of course, you are allowed to use the array that is coming in as a parameter.