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
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
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);
}
}
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.
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 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.
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.
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))
Login/Signup to comment