Question : 3 – Left Rotation
Problem Statement
A left rotation operation on an array shifts each of the array’s elements unit to the left. For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2].
Given an array of integers and a number, , perform left rotations on the array. Return the updated array to be printed as a single line of space-separated integers.
Function Description
Complete the function rotLeft in the editor below. It should return the resulting array of integers.
rotLeft has the following parameter(s):
- An array of integers .
- An integer , the number of rotations.
Input Format
The first line contains two space-separated integers and , the size of and the number of left rotations you must perform.
The second line contains space-separated integers a[i].
Constraints
Output Format
Print a single line of space-separated integers denoting the final state of the array after performing d left rotations.
Sample Input
5 4
1 2 3 4 5
Sample Output
5 1 2 3 4
Explanation
When we perform d=4 left rotations, the array undergoes the following sequence of changes:
[1,2,3,4,5] → [2,3,4,5,1] → [3,4,5,1,2] → [4,5,1,2,3] → [5,1,2,3,4]
Test Case : 1
Input (stdin)
Expected Output
Test Case : 2
Input (stdin)
- 20 10
- 41 73 89 7 10 1 59 58 84 77 77 97 58 1 86 58 26 10 86 51
Expected Output
- 77 97 58 1 86 58 26 10 86 51 41 73 89 7 10 1 59 58 84 77
int main()
{
int n,d;
cin >> n >> d;
int arr[n];
for(int i=0;i> arr[i];
for(int i=(d%n) ;i<n+(d%n) ; i++)
cout << arr[i%n];
}
for question 3
#include
using namespace std;
int main()
{
int n,d;
cin >> n >> d;
int arr[n];
for(int i=0;i> arr[i];
for(int i=(d%n);i<n+(d%n);i++)
cout << arr[i%n] << " ";
}
In which language is the automata question given?will we get the option to select the programming language in that?
We provide the coding questions in C and C++
what are the programming languages that will be given for the Wipro turbo challenge coding round?
Here are the languages thar are choosable in the Exam:
C
C++
Java
Python
coding in wipro is tough or moderate
Hi Ananya,
Coding is moderate in the Wipro Exam.
i have ordered both coding and verbal sections for wipro, amount for both materials is debited but i m nt able to access the material,plz check.
Hi shilpa,
You can find the steps to access the Paid Materials from here -https://prepinsta.com/steps-to-access-paid-material/
Thanks Prepinsta, i gave exam yesterday around 2 questions got repeated from this page and around 40-50% of the questions were similar or repeated from your online classes :).
Is there any course for interview preparation also
Hi Saurabh, we are really glad that your exam went well.
And for Interview Preparation, you may just go through our Interview Experiences Dashboards – https://prepinsta.com/interview-experience/Wipro/
Wipro Coding Questions
Yes, Python is allowed as an coding language.
You can check detailed syllabus for Wipro here – https://prepinsta.com/wipro-syllabus/