Infosys Specialist Programmer Coding Questions and Answers | Infosys Specialist Programmer Important Coding Questions | Infosys SP Coding Question with Answer | Infosys SP Coding Questions
Infosys Specialist Programmer Coding Questions and Answers: The Coding Questions and Answers is very important in the IT Sector and Private Job Sector. Now days candidates are mostly interested in the off-Campus drive and private jobs. Eagerly prepare for the Coding Interview, Assessment Test, and attend the many samples online test for Private jobs. Following of the hiring, Infosys issued the Specialist Programmer for eligible and capable candidates. The Infosys Specialist Programmer selection process coding test, technical test etc., The Coding Interview round will be asked many questions through sample of C, C++, Java, Python Programming Languages. Thoroughly prepare for the Infosys Specialist Programmer Coding Interview. Here we uploaded major common Infosys SP Coding Questions and Infosys Specialist Programmer Coding Questions. Applicants must prepare Infosys SP Coding Questions and Answers.
You have spent a time to solve the Infosys Specialist Programmer Coding Questions while using this page. The Very Infosys SP Coding questions consist of each programming languages. So, candidates prepare all programming languages on one by one. Variety of the sample Infosys Specialist Programmer Coding Questions makes confidence to attend the Infosys Specialist Programmer. Once you have selected in the Infosys coding Interview round, you will be move on further selection process. The coding interview round is main part of the Infosys Hiring. Candidates focused to prepare Infosys SP Coding Questions 2024 and Infosys Specialist Programmer Coding Questions with Solutions.
Infosys Specialist Programmer Coding Questions 2024
| Company Name | Infosys |
| Name of the Post | Specialist Programmer |
| Category | Coding Questions and Answers |
| Official website | infosys.com |
Infosys Specialist Programmer Coding Questions with Answers
Question 1:
Problem Statement :
A subarray of array A is a segment of contiguous elements in array A.
Given an array A of N elements, you can apply the following operations as many times as you like:
– Choosing a subarray [L, R] and subtracting 1 from each element in this subarray. The cost of this operation is X.
– Choosing an index i such that A[i] is positive, and setting A[i] = 0. The cost of this operation in Y.
Your task is to make all the elements equal to 0 and find the minimum cost to do so.
Input Format
- The first line contains an integer, N., denoting the number of elements in A.
- The next line contains an integer, X, denoting the cost of the first operation.
- The next line contains an integer. Y, denoting the cost of the second operation
- Each line i of the N subsequent lines (where 1 <=i<= N) contains an Integer describing Ai.
Constraints
- 1<=N<=10^5
- 1<=X<=10
- 1<=Y<=10^4
- 1<=A[i]<=10^8
Sample Input 1
1
1
10
1
Sample Output 1
1
Explanation:
N=1 X=1 Y=10 A=[1]. The optimal solution is to perform one operation of the first type on the subarray [1,N].
Sample Input 2
3
1
1
1
1
1
Sample Output 2
1
Explanation:
N=3 X=1 Y=1 A=[1,1,1] The optimal solution is to perform one operation of the first type on the subarray[1,N];
C++
#include <iostream> using namespace std; int main () { int arr[] = { 1, 1, 1 }; int X = 1; int Y = 1; int ans = 0; int arrSize = sizeof (arr) / sizeof (arr[0]); for (int i = 0; i < arrSize; i++) { arr[i]--; } ans = ans + X; for (int i = 0; i < arrSize; i++) { if (arr[i] != 0) { arr[i] = 0; ans = ans + Y; } } cout << ans; return 0; }
JAVA
n = 1 x = 1 y = 10 arr = [1] ans = 0 arrSize = len(arr) for i in range(arrSize): arr[i] = arr[i] - 1 ans = ans + x for i in range(arrSize): if arr[i] != 0: arr[i] = 0 ans = ans + y print(ans)
Problem Statement :
Wael is well-known for how much he loves the bitwise XOR operation, while kaito is well known for how much he loves to sum numbers, so their friend Resli decided to make up a problem that would enjoy both of them. Resil wrote down an array A of length N, an integer K and he defined a new function called Xor- sum as follows
- Xor-sum(x)=(x XOR A[1])+(x XOR A[2])+(x XOR A[3])+…………..+(x XOR A[N])
Can you find the integer x in the range [0,K] with the maximum Xor-sum (x) value?
Print only the value.
Input format
- The first line contains integer N denoting the number of elements in A.
- The next line contains an integer, k, denoting the maximum value of x.
- Each line i of the N subsequent lines(where 0<=i<=N) contains an integer describing Ai.
Constraints
- 1<=N<=10^5
- 0<=K<=10^9
- 0<=A[i]<=10^9
Sample Input 1
1
0
989898
Sample Output 1
989898
Explanation:
Xor_sum(0)=(0^989898)=989898
Sample Input 2
3
7
1
6
3
Sample Output 2
14
Explanation
Xor_sum(4)=(4^1)+(4^6)+(4^3)=14.
Sample Input 3
4
9
7
4
0
3
Sample Output 3
46
Explanation:
Xor_sum(8)=(8^7)+(8^4) +(8^0)+(8^3)=46.
C++
#include<bits/stdc++.h> using namespace std; unordered_map < int, int >L; int main () { int n, k, m; cin >> n >> k; vector < int >v (n); for (int i = 0; i < n; i++) { cin >> m; v[i] = m; int j = 0; while (m) { L[j] += (m & 1); m >>= 1; j++; } } int j = 0, K = k, ans = 0, ans2 = 0; while (K) { j++; K >>= 1; } for (int i = j; i > 0; i--) { if (L[i - 1] < n - L[i - 1]) ans != 1; ans <<= 1; } ans >>= 1; while (ans > k) { ans &= 0; ans <<= 1; k <<= 1; } for (auto i:v) ans2 += ans ^ i; cout << ans2; }
JAVA
import java.util.*; class Main { public static void main (String[]args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt (); int k = sc.nextInt (); int arr[] = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt (); int res = 0, max = Integer.MIN_VALUE; for (int i = 0; i <= k; i++) { res = 0; for (int j = 0; j < n; j++) res = res + (i ^ arr[j]); max = Math.max (res, max); } System.out.println (max); } }
PHYTHON
def Xor_sum(x, arr): xorSum = sum(arr) for i in range(1, x): s = 0 for j in arr: s += i ^ j if s > xorSum: xorSum = s return xorSum n = 4 x = 9 arr = [7, 4, 0, 3] print(Xor_sum(x, arr))
Question 3:
Problem Statement :
Given an array A of N elements. You should choose a value B such that (B>=0), and then for each element in A set A[i]=A[i](+)B where is the bitwise XOR.
Print the minimum number of inversions in array A that you can achieve after choosing the value of B optimally and setting A[i] = A[i] (+) B. Since the answer might be large, print it modulo (10^9+7)
Input Format
- The first line contains an integer, N. denoting the number of elements in A
- Then the next line contains N elements, denoting the elements in A.
Input :
4
1 0 3 2
Output
1
C++
Find the smallest and largest number in an Array
Answer:
Sample Input
[3, 1, 56, 34, 12, 9, 98, 23, 4]C++
JAVA
PHYTHON
arr = [3, 1, 56, 34, 12, 9, 98, 23, 4] minVal = min(arr) maxVal = max(arr) print(f"Smallest Number: {minVal}") print(f"Largest Number: {maxVal}")
Output
Smallest Number: 1
Largest Number: 98
Question 5:
How do you rotate a matrix by 90 degrees? Write a program.
Answer:
Sample Input:
1 2 3
4 5 6
7 8 9
PHYTHON
JAVA
public static void main(String[] args) { // Input matrix
}
Output:
Rotated Matrix:
7 4 1
8 5 2
9 6 3
While using this page to get an Infosys Off Campus Coding Questions with Answers and Infosys Coding Interview Coding Questions. Kindly watch dailyrecruitment.in site.
| INSTAGRAM LINK | FOLLOW NOW >> |
| JOB ALERT ON TELEGRAM | JOIN NOW>> |
Govt Jobs by Qualifications
| Education & Vacancies | Salary | Apply Link |
|---|---|---|
| 12th Pass Govt Jobs - 18,000+ Vacancies | Rs. 5,200 - 92,300 | Apply Now |
| ITI Pass Jobs - 3,500 Vacancies | Rs. 5,200 - 35,000 | Apply Now |
| Any Graduate Jobs - 19,100 Vacancies | Rs. 5,200 - 92,300 | Apply Now |
| Central Govt Jobs | Rs. 5,200 - 17,000 | Apply Now |
| Bank Jobs - 1,000 Vacancies | Rs. 5,200 - 29,200 | Apply Now |
| Diploma Jobs - 9,300 Vacancies | Rs. 5,200 - 35,000 | Apply Now |
| BTech/BE Jobs - 18,000 Vacancies | Rs. 15,000 - 1,00,000 | Apply Now |
| Data Entry Jobs - 1,300 Vacancies | Rs. 5,200 - 29,200 | Apply Now |
| Private Jobs | Rs. 10,000 - 67,700 | Apply Now |





