Nagarro Coding Questions
Nagarro Coding Question with Solutions 2023
Nagarro Coding Questions and Answers most important Test Round. It is an elimination round and the student is given a leverage to choose any coding language in which he/she is comfortable with.
There is a Programming Test of 150 minutes which is necessary for a student to qualify to further sit in the virtual interview process for the position of Software Developer as well as Commando Software Developer.
About Nagarro
Nagarro helps businesses, from early-stage startups to Global 50 industry leaders, achieve their strategic objectives by providing outsourced software development services.
Their main office is in Munich, Germany, and we also have subsidiaries there as well as in New York, Mexico, Frankfurt, and Stockholm.
1. Software Developer
2. (Commando Software Developer
Nagarro Recruitment Process
The Nagarro Recruitment Process contains the following rounds.
- Aptitude test and technical objective test
- Programming Test
- Virtual Interview
We have even tabulated some more information for your reference and understanding.
Nagarro | Related Information |
---|---|
Batch | 2023 |
Course | B.TECH CSE/ECE/IT, MCA, M.Tech (CSE) |
Education |
|
Rounds |
|
Cost to Company (CTC) |
|
Training Period | 6 to 8 months |
Salary / stipend paid during training |
|
Remember it might vary from college to college as well as off campus
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Sample Nagarro Coding Questions and Answers 2023
QUESTION 01: Password ASCII
Problem statement : Aman, who is working at a software company forgot the password of his Linkedin id.But he knows the ASCII values of his password in reverse order. Help aman to find the password.
To decode the password, first reverse the string of digits, then successively pick valid values from the string and convert them to their ASCII equivalents. Some of the values will have two digits, and others three. Use the ranges of valid values when decoding the string of digits.
Some of the ASCII values are given with their characters:
- The ASCII value of A to Z is 65 to 90.
- The ASCII value of a to z is 97 to 122.
- The ASCII value of space characters is 32.
Note: The password only has alphabets and blank spaces.
Given a string , decode the password by following the steps mentioned above.
Constraints:
- 1<= |s| <=10^5
- s[i] is an ascii character in the range [A-Za-z] or a space character
Sample Input:
- 796115110113721110141108
Sample Output:
- PrepInsta
Explanation
- The reversed string will be 801141011127311011511697, which if analysed as ascii will be “PrepInsta”
Solution:
#include <bits/stdc++.h> using namespace std; string s1,s; int n; void fun(int i){ if(i>=s.length()) return; string s2=s.substr(i,2); int j=stoi(s2); if(j==32) s1+=" "; else if((j>=65&&j<=91)||(j>=97&&j<=99)) s1+=char(j); else { s2=s.substr(i,3);s1+=char(stoi(s2)); fun(i+3);return; } fun(i+2); } int main(){ s1="";cin>>s; reverse(s.begin(),s.end()); fun(0); cout<<s1; }
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String str = sc.next(); char arr[] = str.toCharArray(); String current = ""; String result = ""; for(int i=arr.length-1;i>0;i=i-2){ current = ""; current = "" + arr[i] + arr[i-1]; int n = Integer.parseInt(current); if(n == 32) result +=" "; else if((n>=65 && n<=90 )|| (n>=97 && n<=99)) result += (char)n; else{ if(i-2<0) break; current += arr[i-2]; n=Integer.parseInt(current); result +=(char)n; i--; } } System.out.println(result); } }
s = input() s = s[::-1] i = 0 res = "" while(i<len(s)-1): x = s[i]+s[i+1] if x == "32": res += " " elif int(x) in range(65,91) or int(x) in range(97,100): res += chr(int(x)) elif i+2<len(s): x = x+s[i+2] res += chr(int(x)) i += 1 i += 2 print(res)
QUESTION 02 : Maximum Revenue
Problem statement : Amit is a salesman who wishes to know the maximum revenue received from a given item of the N products each day . Amit has a sales record of N products for M days.Helo amit to find the highest revenue received each day.
Input :
- The first line of the input consists of two space-separated integers- day(M) and item(N) representing the days and the products in the sales record.
- The next M lines consist of N space separated integers representing the sales revenue from each product each day.
Output:
- Print m space-separated integers representing the maximum revenue received each day .
Example Input:
- 3 4
- 101 123 234 344
- 143 282 499 493
- 283 493 202 304
Output:
- 344 499 493
Explanation:
- The maximum revenue received on the first day is 344 , followed by a maximum revenue of 499 on the second day and a maximum revenue of 493 on the third day.
#include <bits/stdc++.h> using namespace std; int main(){ int m,n, i,j; cin >> m; cin >> n; int arr [m][n]; for(i = 0;i < m;i++){ for (j=0;j<n;j++){ cin >> arr[i][j]; } } for (i = 0;i < m;i++){ int max = INT_MIN; for(j=0;j<n;j++){ if(arr[i][j]>max){ max = arr[i][j]; } } cout << max << " "; } return 0; }
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int m=sc.nextInt(); int n=sc.nextInt(); int arr[][]=new int[m][n]; int i,j; for(i=0;i<m;i++){ for (j=0;j<n;j++){ arr[i][j]=sc.nextInt(); } } for (i=0;i<m;i++){ int max = Integer.MIN_VALUE; for(j=0;j<n;j++){ if(arr[i][j]>max){ max = arr[i][j]; } } System.out.println(max); } } }
m = int(input()) n = int(input()) arr = [] for i in range(0, m): ar = [] for j in range(0, n): ar.append(int(input())) arr.append(ar) for i in arr: print(max(i), end=" ")
QUESTION 03 : Device Name System
Problem statement : Rocky is a software engineer and he is creating his own operating system called “myFirst os”. myFirst os is a GUI (Graphical user interface) based operating system where everything is stored in files and folders. He is facing issues on creating unique folder names for the operating system . Help rocky to create the unique folder name for it’s os.If folder name already exists in the system and integer number is added at the name to make it unique. The integer added starts with 1 and is incremented by 1 for each new request of an existing folder name. Given a list of folder names , process all requests and return an array of corresponding folder names.
Example
- n=5
- foldername= [‘home’ , ‘myfirst’ ,’downloads’, ‘myfirst’, ‘myfirst’]
- Foldername[0] = ‘home’ is unique.
- Foldername[1] = ‘myfirst’ is unique.
- foldername [2] =’downloads’ is unique.
- Foldername[3] =’myfirst’ already exists in our system. So Add1 at the end of the folder name i.e foldername[3] =”myfirst1″
- Foldername[4 ]=’myfirst’ also already exists in our system.So add 2 at the end of the folder name i.e. foldername[4]=”myfirst2″.
Function description
- Complete the function folderNameSystem In the editor below
- folderNameSystem has the following parameters
- string foldername[n]: an array of folder name string in the order requested
Returns:
- String[n]: an array of strings usernames in the order assigned
Constraints
- 1<=n<=10^4
- 1<=length of foldername[i]<20
- foldername[i] contains only lowercase english letter in the range ascii[a-z]
Input Format:
- The first line contains an integer n , denoting the size of the array usernames Each line i of the n subsequent lines (where i<=0<=n) contains a string usernames[i] representing a username request in the order received.
Sample case 0
- 4
- home
- download
- first
- first
Sample Output 0
- home
- download
- first
- first1
Explanation 0
- foldername[0] = ‘home’ is unique
- foldername[1]=’download’ is unique
- foldername[2]= ‘first’ is unique
- foldername[3]=’first’ is already existing . so add 1 to it and it become first1
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<string> v(n); for(int i=0;i<n;i++) cin>>v[i]; map<string,int> m; for(auto i:v){ if(m[i]) cout<<i<<m[i]<<endl; else cout<<i<<endl; m[i]++; } }
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); LinkedHashMap<String, Integer> map=new LinkedHashMap<>(); for(int i=0;i<n;i++){ String str=sc.next(); if(map.containsKey(str)){ int count=map.get(str); count = count+1; map.put(str,count); } else map.put(str,1); } Set s = map.entrySet(); Iterator itr = s.iterator(); while(itr.hasNext()){ Map.Entry m=(Map.Entry)itr.next(); int value=(Integer)m.getValue(); System.out.println(m.getKey()); value--; for(int i=1;i<=value;i++){ System.out.println(m.getKey()+""+i); value--; } } } }
n=int(input()) arr = [] ans = "" for i in range(n): arr.append(input()) print() for i in range(n): if arr[:i+1].count(arr[i])>1: ans = arr[i]+str(arr[:i+1].count(arr[i])-1) else: ans = arr[i] print(ans)
Question 04 : Duplicates
Problem statement : The principal has a problem with repetitions. Everytime someone sends the same email twice he becomes angry and starts yelling. His personal assistant filters the mails so that all the unique mails are sent only once, and if there is someone sending the same mail again and again, he deletes them. Write a program which will see the list of roll numbers of the student and find how many emails are to be deleted.
Sample Input:
6
1
3
3
4
3
3
Sample Output:
3
#include<bits/stdc++.h> using namespace std; map<int,int> m; int main() { int n,a,ans=0; cin>>n; while(n--) { cin>>a; m[a]++; if(m[a]>1) ans++; } cout<<ans; }
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); TreeSet list=new TreeSet<>(); for(int i=0;i<n;i++) list.add(sc.nextInt()); System.out.println(Math.abs(n-list.size())); } }
def countDuplicate(numbers): c=0 for i in set(numbers): if numbers.count(i)>1: c+=numbers.count(i)-1 return c n=int(input()) numbers=[] for i in range(n): numbers.append(int(input())) print(countDuplicate(numbers))
Question 05 : PrepInsta Name : Borrow Number
Problem statement : You have two numbers number1 and number2, your job is to check the number of borrow operations needed for subtraction of number1 from number2. If the subtraction is not possible
then return the string not possible.
Example :
- 754
- 658
Answer :
- 2
- 654
- 666
#include <bits/stdc++.h> using namespace std; int main() { string s1,s2; int c=0,f=0; cin>>s1>>s2; if(stoi(s1)< stoi(s2)) {cout<<"Impossible";} reverse(s1.begin(),s1.end()); reverse(s2.begin(),s2.end()); for(int i=0;i< s1.length();i++) if(s1[i]< s2[i]) {f=1;c++;} else if(s1[i]==s2[i]) { if(f==1) {c++;} f=0; } else f=0; cout<< c; }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int number1=sc.nextInt(); int number2=sc.nextInt(); int count=0; if(number1< number2) { System.out.println("Not possible"); } else { boolean flag=false; while(number1!=0 && number2!=0) { int temp1=0; int temp2=number2%10; if(flag) temp1=number1%10-1; else temp1=number1%10; if(temp1< temp2) { count++; flag=true; } else flag=false; number1=number1/10; number2=number2/10; } System.out.println(count); } } }
number1=int(input()) number2=int(input()) count=0 if(number1< number2): print("Not possible") else: flag=0 while(number1!=0 and number2!=0): temp1=0 temp2=number2%10 if(flag): temp1=number1%10-1 else: temp1=number1%10 if(temp1< temp2): count+=1 flag=1 else: flag=0 number1=number1//10 number2=number2//10 print(count)
FAQs on Naarro Coding Questions with Solutions
Question 1: Question 1: What is the difficulty level of Coding in Nagarro?
The coding level of Nagarro is quite difficult, you will be evaluated on the basis of in-depth knowledge.
Question 2: Is Nagarro exam difficult to crack?
Nagarro exam is of Medium Difficulty. They put emphasis on analytical thinking and problem solving skills of the candidate.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment