Offline 2
Offline 2
Offline 2: Array
Problem Statement
You are given a sequence of integers. Find the number that appears most
frequently in the array and print the number followed by its count. If multiple
numbers have the same maximum frequency, print the number with the first
occurrence in the array.
Input Format
Output Format
● Print two space-separated integers: the most frequent number and its count.
The goal is to find the number with the highest frequency in the array and its count.
If there’s a tie, choose the number that appears first in the array.
Problem Statement
You are given a sequence of numbers and a shift amount. Perform a circular shift
on the array.
A positive shift amount indicates a right circular shift, and a negative shift
amount indicates a left circular shift.
A circular shift moves all elements in the array by a specified number of positions,
with elements wrapping around to the opposite end if they fall off the array.
● Positive shift (k > 0): Right circular shift. Each element moves k positions
to the right. Elements that exceed the array's end wrap around to the
beginning.
● Negative shift (k < 0): Left circular shift. Each element moves |k|
positions to the left. Elements that fall below index 0 wrap around to the end.
Input Format
Output Format
4 5 1 2 3
2 3 4 5 1
Explanation for Samle IO No-1
Original: 1 → 2 → 3 → 4 → 5
Shift amount: k = 2 (right shift)
Step: Move each element 2 positions right circularly
Result: 4 → 5 → 1 → 2 → 3
Submission Guideline:
Please do not copy from any sources (friends, internet, AI tools like
ChatGPT, etc.). Doing so will result in a -100% penalty.
Students must strictly follow the input and output format. Do not
include any extra print statements, as they may cause the solution
to be rejected. Also follow the submission guideline.