SAP Coding Questions on this page will help you to know more about the coding section of SAP recruitment drive. The section carries a heavy weightage and is an elimination round.
Get to know everything about SAP recruitment and coding questions on this page. You’ll get detailed information about SAP Eligibility Criteria, Recruitment Process and Salary Breakdown.
About SAP
SAP enables the world to function more efficiently and enhances people’s lives through a global network of partners, clients, workers, and thought leaders.
As the pioneer in enterprise application software, we improve business operations for organisations of all sizes and across all sectors by redefining ERP and building networks of intelligent firms that offer supply chain transparency, resilience, and sustainability.
Recruitment Process at SAP
The recruitment process of SAP is mentioned here which can help you to understand the process opted by SAP to recruit candidates for the position of SAP Scholar.
The SAP Recruitment Process contains the mentioned rounds.
MCQ and Coding
Virtual Interview
We have even tabulated some more information for your reference and understanding.
SAP
Related Information
Batch
2023
Course
B.Tech (CS / IT / ECE / EE)
Education
Graduation Marks – 70% and above
10th and 12th Marks – 60% and above apply
No backlogs
Rounds
MCQ and Coding is of 1hr 15 minutes
Number of Sections – 3
All rounds will be elimination rounds
Cost to Company (CTC)
6.52 LPA
Salary Breakdown
4.2LPA Stipend & 2.32LPA Benefits
Imporatant information about MCQ and CodingMCQ is a section which contains mixed questions of Quantitative Aptitude, Logical Reasoning, Verbal Ability and Computer Fundamentals.
It contains 2 coding questions.
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
You’re given a string where multiple characters are repeated consecutively. You’re supposed to reduce the size of this string using mathematical logic given as in the example below :
#include <bits/stdc++.h>
using namespace std;
int ans = 0, mx = 0;
void Func(int a) {
int c = 0, k = a;
for (int i = 2; i <= a; i++)
while (a % i == 0) {
a /= i;
c++;
}
if (c > mx) {
mx = c;
ans = k;
}
}
int main() {
int a, b;
cin >> a >> b;
for (int i = a; i <= b; i++)
Func(i);
cout << mx << endl << ans;
}
import java.util.Scanner;
public class Main {
static int ans = 0;
static int mx = 0;
public static void Func(int a) {
int c = 0;
int k = a;
for (int i = 2; i <= a; i++) {
while (a % i == 0) {
a /= i;
c++;
}
}
if (c > mx) {
mx = c;
ans = k;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
for (int i = a; i <= b; i++)
Func(i);
System.out.println(mx + "\n" + ans);
}
}
mx = 0
ans = 0
def Func(a):
global mx
global ans
c = 0
k = a
i = 1
while i <= a:
i += 1
while a % i == 0:
a /= i
c += 1
if c > mx:
mx = c
ans = k
a, b = map(int, input().split())
for i in range(a, b + 1):
Func(i)
print(mx)
print(ans)
Question 2 : Sum of K Farthest items
Problem Statement :
You are given an array of length “len” ,another item called k and an integer value x. Your job is to find the sum of k farthest items in the array from x.
First line has len, k and x respectively 2nd line has the array
Example :
Input : 5 3 20 21 4 15 17 11
Output : 30
4, 15 and 11 are farthest from 20. Thus, their sum will be the answer.
#include <bits/stdc++.h>
using namespace std;
int main() {
int len;
cin >> len;
int k;
cin >> k;
int x;
cin >> x;
vector < int > arr;
for (int i = 0; i < len; i++) {
int t;
cin >> t;
arr.push_back(t);
}
int max = INT_MIN;
int sum = 0, index = -1;
for (int i = 0; i < k; i++) {
max = INT_MIN;
for (int j = 0; j < len; j++) {
if (arr[j] == INT_MIN)
continue;
int temp = abs(x - arr[j]);
if (max < temp) {
max = temp;
index = j;
}
}
//System.out.println(arr[index]);
sum = sum + arr[index];
arr[index] = INT_MIN;
}
cout << sum;
return 0;
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int len = sc.nextInt();
int k = sc.nextInt();
int x = sc.nextInt();
int arr[] = new int[len];
for (int i = 0; i < len; i++)
arr[i] = sc.nextInt();
int max = Integer.MIN_VALUE;
int sum = 0, index = -1;
for (int i = 0; i < k; i++) {
max = Integer.MIN_VALUE;
for (int j = 0; j < len; j++) {
if (arr[j] == Integer.MIN_VALUE)
continue;
int temp = (int) Math.abs(x - arr[j]);
if (max < temp) {
max = temp;
index = j;
}
}
sum = sum + arr[index];
arr[index] = Integer.MIN_VALUE;
}
System.out.println(sum);
}
}
len, k, x = map(int, input().split())
arr = list(map(int, input().split()))
sum, index = 0, -1
for i in range(k):
max = -9999999
for j in range(len):
if arr[j] == -9999999:
continue
temp = abs(x - arr[j])
if max < temp:
max = temp
index = j
sum = sum + arr[index]
arr[index] = -9999999
print(sum)
Question 3 : Find Nth largest and smallest
Problem Statement :
Write a program to find the nth largest and nth smallest item in the array and print them in the same line.
Input Format The first line has the following – Size of array, value of n 2nd line has the array
Output Format Nth largest and nth smallest respectively
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];
for (int i = 0; i < m; i++)
arr[i] = sc.nextInt();
Arrays.sort(arr);
System.out.println(arr[n - 1] + " " + arr[m - n]);
}
}
//By solving above equation you will get it as (a+b)^3
//C is not used in the equation so we can omit that
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int sum;
sum = (a + b) * (a + b) * (a + b);
cout << sum;
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int sum;
sum = (a + b) * (a + b) * (a + b);
System.out.println(sum);
}
}
# By solving above equation you will get it as (a+b)^3
# C is not used in the equation so we can omit that
a, b, c = map(int, input().split())
print((a + b) ** 3)
Question 5 :Find no. of tyres
Problem Statement :
In the city, there are a bunch of dealerships who sell bikes & cars. A function is there which tells how many dealerships there are and the total number of cars in each dealership.
Your job is to calculate how many tyres would be there in each dealership. If you are using the predefined function use this structure,
Struct dealership { Int cars; Int bikes; }
Input : Output : 3 20 4 2 16 4 0 8 1 2
Explanation :
There are total 3 dealerships
Dealerships1 contains 4 cars and 2 bikes
Dealerships2 contains 4 cars and 0 bikes
Dealerships3 contains 1 cars and 2 bikes
Total number of tyres in dealerships1 is (4 x 4) + (2 x 2) = 20
Total number of tyres in dealerships2 is (4 x 4) + (0 x 2) = 16
Total number of tyres in dealerships3 is (1 x 4) + (2 x 2) = 8
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int dealership = sc.nextInt();
while (dealership--> 0) {
int cars = sc.nextInt();
int bikes = sc.nextInt();
System.out.println(cars * 4 + bikes * 2);
}
}
}
Login/Signup to comment