IXR Labs Coding Questions with Solutions
IXR Labs Coding Questions with Solutions 2023
In this page, you will find out IXR Coding Questions and Answers asked in Online Assessments and Technical Interviews involved in the Hiring Process of the Company.
Go through this page to get more details like Job Profile, Job Location, CTC Offered, Steps involved in the recruitment process, etc of the company.
About IXR Labs
IXR is a company established in 2018 in Netherlands that comprises skilled software developers and hardware experts with a retail background. They possess a thorough comprehension of contemporary business procedures, in-store and back-office operations, as well as techniques for maximizing and enhancing productivity. The retail sector, ranging from small fuel stations to large grocery chains, has a significant demand for IXR equipment. Nevertheless, their primary objective is to save time for their clients and offer a seamless shopping experience, eliminating the need to wait in long checkout queues.
About IXR Labs Recruitment Process
The IXR Labs Recruitment Process consists of the following steps :- Online Assessment [ MCQ + Coding ]
- Technical Interview
- HR Discussion
We have mentioned further details of the IXR Labs Recruitment Process in the following Tabular Form
IXR Labs | Related Information |
---|---|
Position : | Junior Unity Developer |
Course : |
|
Eligibility Criteria / Academic Qualification Required : |
|
CTC : |
|
Selection Process : |
|
Joining Location : | Jaipur |
IXR Labs Job Description
Junior Unity Developer
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
IXR Coding Questions and Answers
Question 1 : Number with 2
Problem Statement :
Suppose you are in a number system, where if the number doesn’t contain 2 in the unit digit then the number is not valid. So the first number of the number system is 2, the second number is 12, and the third is 22.
for a given integer n, you have to print the nth element of the number system.
Input Format:
First line, containing n denoting the number of test cases.
then n number of lines for the query.
Output Format:
Print the consecutive number in the number system for each query.
Sample Input:
3
Sample Output:
22
Explanation:
1st number will be 2 , 2nd number will be 12 and third number will be 32
#include <iostrean> using namespace std; int main() { int n; cin >> n; cout << (n - 1) * 10 + 2; return 0; }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); System.out.println((n - 1) * 10 + 2); } }
n = int(input()) print((n - 1) * 10 + 2)
Question 2 : Set Bit
Problem Statement :
You are given an integer, N. You have to turn it into the binary representation of it, and find out how many set bits are there in the binary representation.
Input Format:
The first line contains the integer.
Output Format:
One line containing an integer denoting the number of setbits.
Constraints:
1<=N<=10^9
Sample Input:
8
Output:
1
Output Description:
8 in binary is 1000.
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; while (n) { n &= (n - 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(); int count = 0; while (n != 0) { if ((n & 1) == 1) count++; n = n >> 1; } System.out.println(count); } }
n = int(input()) ans = 0 while n: n &= n - 1 ans += 1 print(ans)
Question 3
Fountains are installed at every position along a one-dimensional garden of length n. Array locations[] represents the coverage limit of these fountains. The ith fountain (where 1sisn) has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ). In other words, the h fountains do not reach outside the boundaries of the garden. In the beginning,all the fountains are switched off. Determine the minimum number of fountains that need to be activated to cover the n length garden by water.
Example
- n = 3
- locations[] = {0, 2, 13, then
- For position 1: locations[1] = 0, max((1 – 0),
- 1) to mini (1+0), 3) gives range = 1 to 1
- For position 2: locations[2] = 2, max((2-2),
- 1) to min( (2+2), 3) gives range = 1 to 3
- For position 3: locations[3] = 1, max( (3-1),
- 1) to min( (3+1), 3) gives range = 2 to 3
- For position 1: locations[1] = 0, max((1 – 0),
For the entire length of this garden to be covered, only the fountain at position 2 needs to be activated.
Function Description
Complete the function fountainActivation in the editor below.
fountainActivation has the following Parameter:
- int locations[n]: the fountain locations
Returns
- int: the minimum number of fountains that must be activated
Constraints
- 1<_n<_ 10^5
- O<_locations[i] <_ mini (n,100) (where 1 <_1<_10^5)
► Input Format For Custom Testing
Sample Case 0
Sample Input For Custom Testing
- 3 ->locations[] size n = 3
- 1 ->locations[] [1, 1, 1
- 1 ->Sample Output
Sample Output
- 1
Explanation
Here, locations = {1, 1, 13
- For position 1: locations[1] = 1, maxi (1 -1), 1) to min((1+1), 3) gives range = 1 to 2
- For position 2: locations[2] = 1, max( (2 -1), 1) to min( (2+1), 3) gives range = 1 to 3
- For position 3: locations[3] = 1, max((3 -1), 1) to min((3+1), 3) gyes range = 2 to 3
If the 2nd fountain is active, the range from position 7 to 3 will be covered. The total number of fountains needed is 1.
#include<bits/stdc++.h> #define ll long long using namespace std; bool compare(pair < int, int > A, pair < int, int > B) { if (A.first = B.first) return A.second < B.second; return A.first < B.first; } int solve(int location[], int n) { pair < int, int > range[n]; for (int i = 0; i < n; i++) { int id = i + 1; range[i].first = max(1, id - location[i]); range[i].second = min(n, id + location[i]); } sort(range, range + n, compare); int i = 0; int ans = 0; while (i < n) { pair < int, int > p = range[i]; ans++; while (i + 1 < n && range[i].first == range[i + 1].first) { p.second = max(p.second, range[i + 1].second); i++; } //cout<<p.second<<" "<<i<<endl; while (i < n && range[i].second <= p.second) i++; //cout<<p.second<<" "<<i<<endl; } return ans; } int main() { int n; cin >> n; int location[n]; for (int i = 0; i < n; i++) cin >> location[i]; cout << solve(location, n) << endl; return 0; }
import java.util.*; class Main { static int minCntFoun(int a[], int N) { int[] dp = new int[N + 1]; Arrays.fill(dp, -1); // Mark the reachable indices for each fountain for (int i = 0; i < N; i++) { int left = Math.max(i - a[i], 0); int right = Math.min(i + a[i]+1, N); dp[left] = Math.max(dp[left], right); } int cntfount = 1; int idxRight = dp[0]; int idxNext = 0; // Traverse the reachable indices and activate fountains for (int i = 0; i < N; i++) { idxNext=Math.max(idxNext,dp[i]); if(i==idxRight){ cntfount++; idxRight = idxNext; } } return cntfount; } // Driver Code public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n = scan.nextInt(); int[] location=new int[n]; for(int i=0;i < n;i++){ location[i]=scan.nextInt(); } System.out.print(minCntFoun(location, n)); } }
Question 4
Karan got bored, so he invented a game to be played on paper. He writes n integers a1, a2, …, an. Each of those integers can be either 0 or 1. He’s allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all values ak for which their positions are in range [i, j] (that is i ≤ k ≤ j). Flip the value of x means to apply operation x = 1 – x.
The goal of the game is that after exactly one move to obtain the maximum number of ones. Write a program to solve the little game of Iahub.
Input
- The first line of the input contains an integer n (1 ≤ n ≤ 100). In the second line of the input there are n integers: a1, a2, …, an. It is guaranteed that each of those n values is either 0 or 1.
Output
- Print an integer — the maximal number of 1s that can be obtained after exactly one move.
Examples
- Input
5
1 0 0 1 0 - Output
4
- Input
4
1 0 0 1 - Output
4
Note
- In the first case, flip the segment from 2 to 5 (i = 2, j = 5). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].
- In the second case, flipping only the second and the third element (i = 2, j = 3) will turn all numbers into 1.
n = int(input()) arr = list(map(int,input().split())) ones =0 for i in range(n): if arr[i] == 1: ones += 1 arr[i] = -1 else : arr[i] = 1 if ones == n: print(n-1) else : max_sum = 0 curr_sum =0 for i in range(n): curr_sum += arr[i] max_sum = max(max_sum, curr_sum) if curr_sum < 0 : curr_sum =0 print(ones + max_sum)
import java.util.*; public class Main { public static void main (String[]args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt (); int countZero = 0, countOne = 0, max = -1; while (n-- > 0) { int temp = sc.nextInt (); if (temp == 1) { countOne++; if (countZero > 0) countZero = countZero - 1; } else { countZero++; if (countZero > max) max = countZero; } } System.out.println (countOne + max); } }
#include<bits/stdc++.h> using namespace std; int main () { int n; cin >> n; int ones = 0; int a[n]; for (int i = 0; i < n; i++){ cin >> a[i]; if (a[i] == 1){ ones++; a[i] = -1; } else a[i] = 1; } if(ones == n) { cout << n - 1; } else { int max_sum = 0, curr_sum = 0; for (int i = 0; i < n; i++) { curr_sum += a[i]; max_sum = max (max_sum, curr_sum); if (curr_sum < 0) curr_sum = 0; } cout << ones + max_sum; } return 0; }
Question 5
Problem Statement : You just received another bill which you cannot pay because you lack the money.
Unfortunately, this is not the first time to happen, and now you decide to investigate the cause of your constant monetary shortness. The reason is quite obvious: the lion’s share of your money routinely disappears at the entrance of party localities.
You make up your mind to solve the problem where it arises, namely at the parties themselves. You introduce a limit for your party budget and try to have the most possible fun with regard to this limit.
You inquire beforehand about the entrance fee to each party and estimate how much fun you might have there. The list is readily compiled, but how do you actually pick the parties that give you the most fun and do not exceed your budget?
Write a program which finds this optimal set of parties that offer the most fun. Keep in mind that your budget need not necessarily be reached exactly. Achieve the highest possible fun level, and do not spend more money than is absolutely necessary.
Input
- The first line of the input specifies your party budget and the number n of parties.
- The following n lines contain two numbers each. The first number indicates the entrance fee of each party. Parties cost between 5 and 25 francs. The second number indicates the amount of fun of each party, given as an integer number ranging from 0 to 10.
- The budget will not exceed 500 and there will be at most 100 parties. All numbers are separated by a single space.
- There are many test cases. Input ends with 0 0.
Output
- For each test case your program must output the sum of the entrance fees and the sum of all fun values of an optimal solution. Both numbers must be separated by a single space.
Example
- Sample input:
50 10
12 3
5 8
16 9
16 6
10 2
21 9
18 4
12 4
17 8
18 9
50 10
13 8
19 10
16 8
12 9
10 2
12 8
13 5
15 5
11 7
16 2
0 0
- Sample output:
50 29
48 32
def knapSack(W, wt, val, n): K = [[0 for x in range(W + 1)] for x in range(n + 1)] for i in range(n + 1): for w in range(W + 1): if i == 0 or w == 0: K[i][w] = 0 elif wt[i-1] <= w: K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]) else: K[i][w] = K[i-1][w] res = K[n][W] res1=res x=0 w = W for i in range(W+1): if(K[n][i]==res): x=i break print(x , res1) b,n=map(int,input().split()) fun=[] cost=[] for i in range(n): x,y=map(int,input().split()) fun.append(y) cost.append(x) (knapSack(b,cost,fun,n))
import java.util.*; class Solution { public static void main (String[]args) { Scanner sc = new Scanner (System.in); while (true) { int budget = sc.nextInt (); int n = sc.nextInt (); if (budget == 0 && n == 0) break; int cost[] = new int[n + 1]; int fun[] = new int[n + 1]; int arr[][] = new int[n + 1][budget + 1]; for (int i = 0; i < n; i++) { cost[i] = sc.nextInt (); fun[i] = sc.nextInt (); } for (int i = 0; i <= n; i++) for (int j = 0; j <= budget; j++) arr[i][j] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= budget; j++) if (cost[i - 1] <= j) arr[i][j] =Math.max (fun[i - 1] + arr[i - 1][j - cost[i - 1]],arr[i - 1][j]); else arr[i][j] = arr[i - 1][j]; } int c = 0; for (int i = 0; i <= budget; i++) { if (arr[n][i] == arr[n][budget]) { c = i; break; } } System.out.println (c + " " + arr[n][budget]); } } }
#includeusing namespace std; int main() { int w, n; x: cin >> w >> n; if (w == 0 and n == 0) goto r; else { int ct[n], val[n]; for (int i = 0; i < n; i++) { cin >> ct[i] >> val[i]; } int t[n + 1][w + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= w; j++) t[i][j] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= w; j++) { if (ct[i - 1] <= j) t[i][j] = max(val[i - 1] + t[i - 1][j - ct[i - 1]], t[i - 1][j]); else t[i][j] = t[i - 1][j]; } } int cost = 0; for (int i = 0; i <= w; i++) { if (t[n][i] == t[n][w]) { cost = i; break; } } cout << cost << " " << t[n][w] << endl; goto x; } r: return 0; }
FAQs related to IXR Labs Coding Questions
Question 1: How many rounds are there in IXR Labs Hiring Process?
There are in total three rounds in the IXR Labs Hiring Process which includes:-
- Online Assessments (MCQ + Coding)
- Technical Interview
- HR Discussion
Question 2: Is Coding questions asked in IXR Labs Recruitment Process?
Yes, Coding Questions are included in Online Assessment and Technical Interview of IXR Labs.
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