The Silicon Partners Coding Questions
The Silicon Partners Coding Questions with Solutions
In this page, you will find out The Silicon Partners 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 The Silicon Partners
TSP (The Silicon Partners) is a US Based IT Consulting Organization headquartered in California. TSP specialize in providing Consulting Services for enterprise technologies like SAP S/4HANA, SuccessFactors Human Experience Management (HXM), SAP Application Management Service, Robotic Process Automation (UiPath), AI / ML and Cloud.
With a global presence in over 10 countries and offshore development centres in Noida and Columbia, TSP has a global footprint with over 400 employees.
About The Silicon Partners Recruitment Process
The The Silicon Partners Recruitment Process consists of the following steps :
- Online Assessment [ MCQ + Coding ]
- Technical Interview with the LEADs
- Discussion with BU Head
- HR Round
We have mentioned further details of the The Silicon Partners Recruitment Process in the following Tabular Form
The Silicon Partners | Related Information |
---|---|
Position : | Technical / Functional Trainee |
Course : |
|
Eligibility Criteria / Academic Qualification Required : |
|
Salary Offered and Terms |
|
Selection Process : |
|
Joining Location : | Noida |
Details about Online Assessment
- There will be question from 5 different sections:
- Aptitude
- Analitical Ability
- Computer Fundamentals
- Communication Skills
- Time Duration : 90 minutes
Skill Set Required
- Excellent Commuication Skills
- Learning Ability
- Certification (Any SAP domain or RPA tool) is an added advantage
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
The Silicon Partners Coding Questions and Answers
Question 1: Stars Between Bars
Given a string s consisting of stars “*” and bars “|” ,an array of starting indices starIndex,and an array of ending indices endIndex,determine the number of stars between any two bars within the substrings between the two indices inclusive . NOTE that in this problem indexing starts at 1.
- A Star is represented as an asterisk [*=ascii decimal 42]
- A Bar is represented as a Pipe [“|”=ascii decimal 124]
Example
s=’|**|*|’
startIndex=[1,1]
endIndex=[5,6]
- For the first pair of indices (1,5) the substrings is “|**|*” . There are 2 stars between a pair of bars
- For the second pair of indices (1,6) the substring is “|**|*|” and there are 2+1=3 stars in between the bars.
- Both of the answers are returned to the array [2,3].
Constraints
- 1<=n<=105
- 1<=StartInde[i]<=endIndex[i]
- Each Character of s is either “*” or “|”
Input Format for Custom testing
First line contains a string S the next line contains an integer n , the no.of elements in startIndex. Each line i of the n subsequent lines contains an integer of startIndex.the next line contains an integer n , the no.of elements in endIndex. Each line i of the n subsequent lines contains an integer of endindex
Sample Input
*|*| → s=”*|*|”
1 → startindex[] size=1
1 → startindex= 1
1 → endindex[] size=1
3 → endindex=3
Sample output:
0
Explanation :
The substring from index =1 to index=3 is “*|*” . there is no consecutive pair of bars in this string.
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int n; cin >> n; int st[n], ed[n]; for (int i = 0; i < n; i++){ cin >> st[i]; st[i]--; } cin>>n; for (int i = 0; i < n; i++){ cin >> ed[i]; ed[i]--; } vector<int> bars; for (int i = 0; i < s.length(); i++){ if (s[i] == '|') bars.push_back(i); } for (int i = 0; i < n; i++){ int idx = lower_bound(bars.begin(),bars.end(),st[i]) - bars.begin(); st[i] = bars[idx]; idx = lower_bound(bars.begin(),bars.end(),ed[i]) - bars.begin(); if(idx == 0 || bars[idx]==ed[i]) continue; ed[i] = bars[idx-1]; } int sz = s.length(); int starCt[sz] = {0}; if(s[0] == '*') starCt[0] = 1; for(int i =1;i<sz;i++){ starCt[i] = starCt[i-1] + (s[i]=='*'); } for(int i =0;i<n;i++){ if(st[i]>=ed[i]){ cout<<0<<endl; } else{ int ans = starCt[ed[i]]; if(st[i]>0) ans-=starCt[st[i]-1]; cout<<ans<<endl; } } return 0; }
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); String str=sc.next(); int n=sc.nextInt(); int startIndex[]=new int[n]; int endIndex[]=new int[n]; for(int i=0;i<n;i++) startIndex[i]=sc.nextInt(); for(int i=0;i<n;i++) endIndex[i]=sc.nextInt(); int count=0; for(int i=0;i<n;i++){ count=0; String sub=str.substring(startIndex[i]-1,endIndex[i]); int start= sub.indexOf("|"); int end=sub.lastIndexOf("|"); for(int j=start;j<end;j++) if(sub.charAt(j)=='*') count++; System.out.print(count+" "); } } }
s=input() start=[] end=[] n=int(input()) for i in range(n): start.append(int(input())) for i in range(int(input())): end.append(int(input())) for i in range(n): Str=s[start[i]-1:end[i]] print(Str.strip('*').count('*'))
Question 2 : Share Holder (R -> Hard)
Problem Statement :
Ratan is a crazy rich person. And he is blessed with luck, so he always made the best profit possible with the shares he bought. That means he bought a share at a low price and sold it at a high price to maximize his profit. Now you are an income tax officer and you need to calculate the profit he made with the given values of stock prices each day. You have to calculate only the maximum profit Ratan earned.
Note that:
Ratan never goes into loss.
Example 1 :
Price=[1,6,2]
Ratan buys it on the first day and sells it on the second.
Example 2 :
Price=[9,8,6]
The Price always went down, Ratan never bought it.
Input Format:
First line with an integer n, denoting the number days with the value of the stack
Next n days, telling the price of the stock on that very day.
Output Format:
Maximum profit done by Ratan in a single line.
Constraints:
Number of days <=10^8
Sample Input for Custom Testing:
STDIN
7
1
9
2
11
1
9
2
Sample Output :
10
Explanation :
The maximum profit possible is when Ratan buys it in 1 rupees and sells it in 11.
#include <bits/stdc++.h> using namespace std; int solve(vector < int > v) { int n = v.size(); if (n == 0) return 0; int mx = v[0]; for (int i = 1; i < n; i++) mx = max(mx, v[i]); if (mx <= 0) return 0; int mxSum = 0; int cSum = 0; for (int i = 0; i < n; i++) { cSum += v[i]; if (cSum < 0) cSum = 0; mxSum = max(mxSum, cSum); } return mxSum; } int main() { int n; cin >> n; int price[n]; for (int i = 0; i < n; i++) cin >> price[i]; vector < int > diff; for (int i = n-2; i >= 0 ; i--) diff.push_back(price[i+1] - price[i]); int ans = solve(diff); if(ans < 0) cout << 0 << endl; else cout<< ans << endl; }
import java.util.*; public class PrepInsta { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int price[] = new int[n]; for(int i=0;i < n;i++) { price[i] = sc.nextInt(); } Vector < Integer > diff = new Vector<>(); for(int i=n-2;i >=0;i--) { diff.add(price[i+1]-price[i]); } int ans = solve(diff); if(ans < 0) { System.out.println(0); }else { System.out.println(ans); } } private static int solve(Vector < Integer > v) { int n = v.size(); if(n==0) { return 0; } int mx = v.get(0); for(int i=1;i < n;i++) { mx = Math.max(mx, v.get(i)); } if(mx <= 0) { return 0; } int mxSum=0,csum=0; for(int i=0;i < n;i++) { csum+=v.get(i); if(csum < 0) csum=0; mxSum = Math.max(csum, mxSum); } return mxSum; } }
def func(diff): n=len(diff) if n==0: return 0 mx=max(diff) if mx <= 0: return 0 mxS=0 cS=0 for i in diff: cS+=i if cS <= 0: cS=0 mxS=max(cS,mxS) return mxS n=int(input()) arr=[] diff=[] ans=[0] for i in range(n): arr.append(int(input()))c++ for i in range(n-1): diff.append(arr[i+1]-arr[i]) ans=func(diff) if ans < 0: print("0") else: print(ans)
Question 3 : Password Creation
Problem Statement: A password manager wants to create new passwords using two strings given by the user, then combined to create a harder-to- guess combination. Given two strings,interleave the characters of the strings to create a new string. Beginning with an empty string, alternately append a character from string a and from string b. If one of the strings is exhausted before the other, append the remaining letters from the other
string all at once. The result is the new password.
Example :
- If a = ‘hackerrank’ and b = ‘mountain’,
- The result is hmaocuknetrariannk.
Function Description :
- Complete the function newPassword in the editor below.
Parameter(s):
- Str : string a
- Str : string b
- Returns:
- Str: new password using two strings
Sample input:
- abc → a=”abc”
- def → b=”def”
Sample output 0:
- Adbecf
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str1 = sc.next(); String str2 = sc.next(); String password = ""; int i, j; for (i = 0, j = 0; i < str1.length() && j < str2.length(); i++, j++) { password = password + str1.charAt(i) + str2.charAt(j); } if (i < str1.length()) password = password + str1.substring(i, str1.length()); if (j < str2.length()) password = password + str2.substring(j, str2.length()); System.out.println(password); } }
def newPassword(a, b): ans = "" if len(a) > len(b): m = len(b) x = a[m:] if len(a) <= len(b): m = len(a) x = b[m:] for i in range(m): ans += a[i] ans += b[i] return ans + x a = input() b = input() print(newPassword(a, b))
Question 4
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]); } } }
#include <bits/stdc++.h> using 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; }
Question 5 :Class Monitor
Problem Statement :
After JEE Mains, some students got admission into an engineering college. Now there is a class consisting of such n students, and the HOD came to say it is time to select the class monitor. But He never gets all of them at one time. So he brought a register, every time he gets someone with less rank than the previous time he cut the name and wrote the name of the student and the rank.
For a given number of ranks he gets each time, you have to predict how many names are cut in the list.
Constraints:
- Number of Visiting<=10^9
- ranks <=10000
Input Format:
- Number of Visiting N in their first line
- N space separated ranks the HOD gets each time
Output Format:
Number of ranks cut in the list
Sample Input:
- 6
- 4 3 7 2 6 1
Sample Output:
- 3
#include <bits/stdc++.h> using namespace std; int main() { int n, p, m = INT_MAX, ans = 0; cin >> n; vector < int > a(n); for (int i = 0; i < n; i++) { cin >> p; if (p < m) { m = p; ans++; } } cout << ans - 1; }
import java.util.Scanner; public class Main { public static void main(String[] args) { int n, p, ans = 0, m = Integer.MAX_VALUE; Scanner sc = new Scanner(System.in); n = sc.nextInt(); for (int i = 0; i < n; i++) { p = sc.nextInt(); if (p < m) { m = p; ans++; } } System.out.print(ans - 1); } }
n = int(input()) a = list(map(int, input().split())) m = a[0] ans = 0 for i in range(1, n): if a[i] < m: m = a[i] ans += 1 print(ans - 1)
FAQs related to The Silicon Partners Coding Questions
Question 1: What should I expect during the interview process?
During the interview process at TSP, you can expect to be asked a series of questions related to your experience, skills, and qualifications . You will be showcasing your skills like:
- Programming languages, including C++, Java, and C
- Experience in building libraries and APIs.
Question 2: Is Coding questions asked in The Silicon Partner Recruitment Process?
Yes, Coding Questions are included in Online Assessment and Technical Interview of TSP.
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