Sopra Steria Coding Questions and Answers
Sopra Steria Coding Questions with Solutions
In this page, you will find out Sopra Steria Coding Questions and Answers asked in Online Assessments and Technical Interviews involved in the Recruitment Process of the Company.
Explore this page for getting more details like the Job Profile, CTC Offered, Service Agreement, Eligibility Criteria, etc of the company.
About Sopra Steria :
Sopra Steria is a leading European Tech company that is mainly popular for its Consulting Services, Software Development – Support Services, and other digital services. Their vision is to promote Digital Transformation of all Industries whether it is Large scale or small-scale ventures.
The company is also having its own subsidiary called Sopra Banking Software, which is known for its Financial Services and Solutions. They generally provide Banking Related Software, Support, and help many Financial Institutions to deploy an efficient Banking System.
About Sopra Steria Recruitment Process :
The Sopra Steria Recruitment Process consists of the following steps :
- Online Assessment [ MCQs Based Aptitude + Technical ]
- Technical Interview
- HR Interview
We have mentioned further details of the Sopra Steria Recruitment Process in the following Tabular Form
Sopra Steria | Related Information |
---|---|
Position : | Engineer Trainee |
Course : |
|
Eligibility Criteria / Academic Qualification Required : |
|
Offered CTC : | ₹ 6 L.P.A |
Selection Process : |
|
Joining Location : |
|
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Sample Sopra Steria Coding Questions with Solutions
Question 1: Consecutive Prime Sum
Problem Description
Question – : Some prime numbers can be expressed as a sum of other consecutive prime numbers.
- For example
- 5 = 2 + 3,
- 17 = 2 + 3 + 5 + 7,
- 41 = 2 + 3 + 5 + 7 + 11 + 13.
Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.
Write code to find out the number of prime numbers that satisfy the above-mentioned property in a given range.
Input Format: First line contains a number N
Output Format: Print the total number of all such prime numbers which are less than or equal to N.
Constraints: 2<N<=12,000,000,000
#include <stdio.h> int prime(int b); int main() { int i,j,n,cnt,a[25],c,sum=0,count=0,k=0; printf("Enter a number : "); scanf("%d",&n); for(i=2;i<=n;i++) { cnt=1; for(j=2;j<=n/2;j++) { if(i%j==0) cnt=0; } if(cnt==1) { a[k]=i; k++; } } for(i=0;i<k;i++) { sum=sum+a[i]; c= prime(sum); if(c==1) count++; } printf(" %d",count); return 0; } int prime(int b) { int j,cnt; cnt=1; for(j=2;j<=b/2;j++) { if(b%j==0) cnt=0; } if(cnt==0) return 1; else return 0; }
Output Enter a number : 43 4
#include <iostream> using namespace std; int prime(int b) { int j,cnt; cnt=1; for(j=2;j<=b/2;j++) { if(b%j==0) cnt=0; } if(cnt==0) return 1; else return 0; } int main() { int i,j,n,cnt,a[25],c,sum=0,count=0,k=0; cout<<"Enter a number : "; cin>>n; for(i=2;i<=n;i++) { cnt=1; for(j=2;j<=n/2;j++) { if(i%j==0) cnt=0; } if(cnt==1) { a[k]=i; k++; } } for(i=0;i<k;i++) { sum=sum+a[i]; c= prime(sum); if(c==1) count++; } cout<<count; return 0; }
Output Enter a number : 5 1
import java.util.Scanner; class Main { static int prime(int b) { int j,cnt; cnt=1; for (j = 2; j <= b/2; j++) { if(b%j==0) cnt=0; } if(cnt==0) return 1; else return 0; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i,j,n=0,cnt,c=0,sum=0,count=0,k=0; Main t = new Main(); int[] a = new int[25]; System.out.println("Enter no"); n = sc.nextInt(); for (i = 2; i <=n ; i++) { cnt=1; for (j = 2; j <= n/2; j++) { if(i%j==0) cnt=0; } if(cnt==1) { a[k]=i; k++; } } for (i = 0; i < k; i++) { sum=sum+a[i]; c=t.prime(sum); if(c==1) count++; } System.out.println(count); } }
Output 43 4
num = int(input()) arr = [] sum = 0 count = 0 if num > 1: for i in range(2, num + 2): for j in range(2, i): if i % j == 0: break else: arr.append(i) def is_prime(sum): for i in range(2, (sum // 2) +2): if sum % i == 0: return False else: return True for i in range(0, len(arr)): sum = sum + arr[i] if sum <= num: if is_prime(sum): count = count + 1 print(count)
Output 20 2
Question 2: Self Sufficient
Problem Statement – Abhijeet is one of those students who tries to get his own money by part time jobs in various places to fill up the expenses for buying books. He is not placed in one place, so what he does, he tries to allocate how much the book he needs will cost, and then work to earn that much money only. He works and then buys the book respectively. Sometimes he gets more money than he needs so the money is saved for the next book. Sometimes he doesn’t. In that time, if he has stored money from previous books, he can afford it, otherwise he needs money from his parents.
Now His parents go to work and he can’t contact them amid a day. You are his friend, and you have to find how much money minimum he can borrow from his parents so that he can buy all the books.
He can Buy the book in any order.
Function Description:
Complete the function with the following parameters:
Name | Type | Description |
N | Integer | How many Books he has to buy that day. |
EarnArray[ ] | Integer array | Array of his earnings for the ith book |
CostArray[ ] | Integer array | Array of the actual cost of the ith book. |
Constraints:
- 1 <= N <= 10^3
- 1 <= EarnArray[i] <= 10^3
- 1 <= CostArray[i] <= 10^3
Input Format:
- First line contains N.
- Second N lines contain The ith earning for the ith book.
- After that N lines contain The cost of the ith book.
Output Format: The minimum money he needs to cover the total expense.
Sample Input 1:
3
[3 4 2]
[5 3 4]
Sample Output 1:
3
Explanation:
At first he buys the 2nd book, which costs 3 rupees, so he saves 1 rupee. Then he buys the 1st book, that takes 2 rupees more. So he spends his stored 1 rupee and hence he needs 1 rupee more. Then he buys the last book.
#include<bits/stdc++.h> using namespace std; int main() { int n, ans =0,sum=0; cin>>n; vector arr1(n),arr2(n); for(int i=0;i<n;i++) cin>>arr2[i]; for(int i=0;i<n;i++) cin>>arr1[i]; for(int i=0;i<n;i++) arr2[i]-=arr1[i]; sort(arr2.begin(),arr2.end(),greater()); for(int i=0;i<n;i++) { sum+=arr2[i]; if(sum<0) {ans+=abs(sum);sum=0;} } cout<<ans; }
n=int(input()) L1=[0] *n L2=[0]*n for i in range(n): L2[i]=int(input()) for i in range(n): L1[i]=int(input()) for i in range(n): L2[i]=L2[i]-L1[i]; L2.sort() su=0 ans=0 for i in range(n): su=su+L2[i] if su<0: ans = ans + abs(su) su=0 print(ans)
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner (System.in); int n=sc.nextInt(); int arr1[]= new int[n]; int arr2[]= new int[n]; for(int i=0; i<n; i++) arr2[i]=sc.nextInt(); for(int i=0; i<n; i++) arr1[i]=sc.nextInt(); for(int i=0; i<n; i++) arr2[i] -= arr1[i]; Arrays.sort(arr2); int sum=0, ans=0; for(int i=n-1; i>=0; i--) { sum+=arr2[i]; if(sum<0) { sum = -sum; ans= ans +sum ; sum=0; } } System.out.println(ans); } }
Question : 3
Problem Statement : 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 Pair { Integer a; Integer b; Pair() {} Pair(Integer a, Integer b) { this.a = a; this.b = b; } public Integer getA() { return a; } public void setA(Integer a) { this.a = a; } public Integer getB() { return b; } public void setB(Integer b) { this.b = b; } } class SortingPair implements Comparator { @Override public int compare(Pair o1, Pair o2) { if (o1.getA() == o2.getA()) { if (o1.getB() < o2.getB()) { return 1; } else { return 0; } } if (o1.getA() < o2.getA()) { return 1; } else { return 0; } } } public class Solution { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int location[] = new int[n]; for (int i = 0; i < n; i++) { location[i] = sc.nextInt(); } System.out.println(solve(location, n)); } private static int solve(int[] location, int n) { Pair range[] = new Pair[n]; for (int i = 0; i < n; i++) { int id = i + 1; range[i] = new Pair(); range[i].setA(Math.max(1, id - location[i])); range[i].setB(Math.min(n, id + location[i])); } Arrays.sort(range, new SortingPair()); int i = 0, ans = 0; while (i < n) { Pair p = range[i]; ans++; while (i + 1 < n && range[i].getA() == range[i + 1].getA()) { p.b = Math.max(p.getB(), range[i + 1].getB()); i++; } while (i < n && range[i].getB() <= p.getB()) { i++; } } return ans; } }
Question 4
Problem Statement : Street Lights are installed at every position along a 1-D road of length n.
Locations[] (an array) represents the coverage limit of these lights. The ith light has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ) (Closed intervals). Initially all the lights are switched off. Find the minimum number of fountains that must be switched on to cover the road.
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 road to be covered, only the light at position 2 needs to be activated.
Function Description
Returns
int: the minimum number of street lights 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
#include#define ll long long using namespace std; bool compare(pair A, pair B) { if (A.first = B.first) return A.second < B.second; return A.first < B.first; } int solve(int location[], int n) { pair 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 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< > n; int location[n]; for (int i = 0; i < n; i++) cin >> location[i]; cout << solve(location, n) << endl; 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 on Sopra Steria Coding Questions
Question 1: Is Coding questions asked in Sopra Steria Recruitment Process?
Yes, coding questions were asked in the Sopra Steria’s 1st Round of recruitment process (the online assessment) and second round (the technical interview).
Question 2: What kind of skills does Sopra Steria look for in job applicants in India?
Sopra Steria typically looks for candidates with technical skills and qualifications in areas such as software development, cloud computing, cybersecurity, and data analytics. They also value soft skills such as teamwork, communication, and problem-solving abilities.
Question 3: In what field does Sopra Steria works?
Sopra Steria works in a variety of fields and industries, including banking and financial services, insurance, healthcare, government and public sector, energy and utilities, aerospace and defense, and transportation. The company also provides business process services, outsourcing solutions, and enterprise resource planning (ERP) services.
Question 4: How long does the recruitment process take at Sopra Steria?
The recruitment process at Sopra Steria in India can vary depending on the role and the number of candidates being considered. On average, the process can take anywhere from a few weeks to several months.
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