KPIT Coding Questions and Answers
KPIT Coding Questions with Solutions
KPIT Coding Questions and Answers page will help you to get sample Coding Questions asked in the Online and Technical Assessments of the Company for hiring the freshers from 2023 and 2024 Batch.
Apart from that you will be getting details on Job Profile, Expected CTC, etc. offered by KPIT Technologies.
About KPIT Technologies
KPIT Technologies is a company that provides consulting and engineering services to the automotive and transportation industries.
With expertise in embedded systems, artificial intelligence, and digital product engineering, KPIT offers innovative solutions for connected vehicles, autonomous driving, and sustainability. Their commitment to customer success and cutting-edge technology makes them a trusted partner in the automotive ecosystem.
This company is headquartered in Pune and has development centers in Europe, the USA, Japan, and China.
Steps of KPIT Hiring Process
Here we have mentioned everything regarding the KPIT Hiring Process for freshers:
- Round 1: Online Assessment [ Aptitude + Technical ]
- Round 2: Technical Interview – 1
- Round 3: Technical Interview – 2
- Round 4: HR Interview
Here we have mentioned some significant details of KPIT hiring process in the following tabular form:
KPIT | Related Information |
---|---|
Position : |
|
Course : |
|
Eligibility Criteria / Academic Qualification Required : |
|
Cost to Company (CTC) | ₹ 4 – 6 L.P.A |
Selection Process : |
|
Details of KPIT Online Assessment and Technical Test :
Rounds | Topics | Time |
---|---|---|
Online Assessment | Aptitude + Domain-Specific Questions | 1 Hr Minutes |
Technical Test 1 | Programming: C, C++, Java, SQL & DBMS. | 60 Minutes |
Technical Test 2 | Advanced Coding: C, C++, Java, SQL & DBMS. | 90 Minutes |
KPIT Technologies usually demands following Skillsets:
- Embedded C / C++
- Python
- Java
- Machine Learning & Artificial Intelligence Concepts
- Automation
Prime Course Trailer
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Sample KPIT Coding Questions with Solutions
Question 1: Mr. Robot’s Password
Mr. Robot is making a website, in which there is a tab to create a password. As with other websites, there are rules so that the password gets complex and none can predict the password for another. So he gave some rules like:
– At least one numeric digit
– At Least one Small/Lowercase Letter
– At Least one Capital/Uppercase Letter
– Must not have space
– Must not have slash (/)
– At least 6 characters
If someone inputs an invalid password, the code prints: “Invalid password, try again”.
Otherwise, it prints: “password valid”.
Input Format:
A line with a given string as a password
Output Format:
If someone inputs an invalid password, the code prints: “Invalid password, try again”.
Otherwise, it prints: “password valid”, without the quotation marks.
Constraints:
Number of characters in the given string <=10^9
Sample input 1:
abjnlL09
Sample output 1:
password valid
Sample input 2:
jjnaskpk
Sample output 2:
Invalid password, try again
#include<bits/stdc++.h> using namespace std; int CheckPassword (char str[], int n) { if (n < 4) return 0; int a = 0, cap = 0, nu = 0, low = 0; while (a < n) { if (str[a] == ' ' || str[a] == '/') return 0; if (str[a] >= 65 && str[a] <= 90) { cap++; } if (str[a] - 32 >= 65 && str[a] - 32 <= 90) { low++; } else if (str[a] - '0' >= 0 && str[a] - '0' <= 9) nu++; a++; } return cap > 0 && nu > 0 && low > 0; } int main () { string s; getline (cin, s); int len = s.size (); char *c = &s[0]; if (CheckPassword (c, len)) cout << "password valid"; else cout << "Invalid password, try again"; }
def CheckPassword(s, n): if n < 4: return 0 cap = 0 nu = 0 lo = 0 for i in range(n): if s[i] == " " or s[i] == "/": return 0 if s[i] >= "A" and s[i] <= "Z": cap += 1 if s[i] >= "a" and s[i] <= "z": lo += 1 elif s[i].isdigit(): nu += 1 if cap > 0 and nu > 0 and lo > 0: return 1 else: return 0 s = input() a = len(s) if CheckPassword(s, a): print("Password valid.") else: print("Invalid password, try again.")
Question 2 : Copycat in exam
Rahul copies in the exam from his adjacent students. But he doesn’t want to be caught, so he changes words keeping the letter constant. That means he interchanges the positions of letters in words. You are the examiner and you have to find if he has copied a certain word from the one adjacent student who is giving the same exam, and give Rahul the markings he deserves.
Note that: Uppercase and lowercase are the same.
Input Format:
First line with the adjacent student’s word
Second line with Rahul’s word
Output Format:
0 if not copied
1 if copied
Constraints:
1<=Length of string<=10^6
Sample Input:
CAR
ACR
Sample Output:
1
import java.util.*; public class Main { public static void main (String[]args) { Scanner sc = new Scanner (System.in); String s1 = sc.next (); String s2 = sc.next (); s1 = s1.toUpperCase (); s2 = s2.toUpperCase (); char arr1[] = s1.toCharArray (); Arrays.sort (arr1); char arr2[] = s2.toCharArray (); Arrays.sort (arr2); String res1 = new String (arr1); String res2 = new String (arr2); if (res1.equals (res2)) System.out.println ("1"); else System.out.println ("0"); } }
s=input() s1=input() s=s.lower() s=sorted(s) s1=s1.lower() s1=sorted(s1) if s1==s: print(1) else: print(0)
#include<bits/stdc++.h> using namespace std; int main() { string s2,s1; cin>>s1>>s2; transform(s1.begin(),s1.end(),s1.begin(),::tolower); transform(s2.begin(),s2.end(),s2.begin(),::tolower); sort(s1.begin(),s1.end()); sort(s2.begin(),s2.end()); cout<< (s2==s1); }
Question 3 : Last student’s ID
Problem Statement :
There is an id code that is supposed to be given to all the aspirants of an exam. It is actually a substring of a given string. That means, the authority takes a string and then assigns all the unique substrings to all the students. Suppose there is a string “abcde”, so the ids of the students will be “a”,”b”,”c”,”d”,”e”,’ab”,”abc”,”abcd”,”abcde”,”bc”,”bcd”,”bcde”,”cd”,”cde”,”de”.
The students are standing in a line according to the lexicographic order of their given ids. You have to find out the id of the last student for the given input string from which the ids are generated.
Input Format:
Single line with the id generating string
Output format:
The last id as per lexicographical order
Constraints:
Number of characters in the string<=10^9
Sample Input:
abdc
Sample output:
dc
Explanation:
The last student will be with the id dc. The order will be
abdc
a
ab
abd
abdc
b
bd
bdc
c
d
dc
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector < string > v; for (int i = 0; i < s.length(); i++) { v.push_back(s.substr(i, s.length() - i)); //cout<<v[i]<<endl; } sort(v.begin(), v.end(), greater < string > ()); cout << v[0]; }
import java.util.*; public class Main { public static String maxString(char set[]) { int n = set.length; String temp = ""; TreeSet < String > list = new TreeSet < > (); for (int i = 0; i < n; i++) { temp = ""; for (int j = i; j < n; j++) { temp = temp + set[j]; list.add(temp); } } return list.last(); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); char arr[] = str.toCharArray(); System.out.println(maxString(arr)); } }
s = input() j = 1 c = 0 while j < len(s): if ord(s[c]) < ord(s[j]): c = j j += 1 print(s[c:])
Question: 4
Problem Statement: You just received another bill that 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
while True: budget, n = map(int, input().split()) if budget == 0 and n == 0: break cost = [0] * (n + 1) fun = [0] * (n + 1) arr = [[0] * (budget + 1) for _ in range(n + 1)] for i in range(n): cost[i], fun[i] = map(int, input().split()) for i in range(n + 1): for j in range(budget + 1): arr[i][j] = 0 for i in range(1, n + 1): for j in range(1, budget + 1): if cost[i - 1] <= j: arr[i][j] = max(fun[i - 1] + arr[i - 1][j - cost[i - 1]], arr[i - 1][j]) else: arr[i][j] = arr[i - 1][j] c = 0 for i in range(budget + 1): if arr[n][i] == arr[n][budget]: c = i break print(c, arr[n][budget])
import java.util.*; public class Main { 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: Amusement park
Problem Statement – Akshay loves to go to WONDERLA , an amusement park. They are offering students who can code well with some discount. Our task is to reduce the cost of the ticket as low as possible.
The cost of tickets can be removed by removing the digits from the price given. They will give some k turns to remove the digits from the price of the ticket. Your task is to help Akshay in coding a program that can help him to reduce the cost of a ticket by removing the digits from its price and getting the maximum possible discount.
Note – You cannot make the cost of a ticket zero. For eg -: If the cost of a ticket is 100, and you have 2 turns to reduce the price, the final price will be 1 and not zero.
Constraints:
- 1 <= number of tickets <= 10^5
- 1 <= K < Number of digits in Price of ticket
Input Format for Custom Testing:
- The first line contains a string,Tickets, denoting the given cost of each ticket.
- The next line contains an integer, K, denoting the number of tickets that is to be removed.
Sample Cases:
- Sample Input 1
203
2 - Sample Output 1
0
#include<bits/stdc++.h> using namespace std; int smallestNumber (string num, int k) { if(num.length()<=k) return 0; unordered_map<char,int> pos; for(int i=0;i < num.length();i++) { pos[num[i]]=i;} string temp=num; sort(num.begin(),num.end()); string ans=num.substr(0,num.length()-k); vector < int > v; for(int i=0;i < ans.length();i++) v.push_back(pos[ans[i]]); sort(v.begin(),v.end()); string ret; for(int i=0;i < v.size();i++) { ret+=temp[v[i]]; } int final=stoi(ret); return final; } int main() { string s; cin >> s; int k; cin >> k; int ans; cout << smallestNumber(s,k)%(int)(pow(10,9)+7); return 0; }
import sys n=input() k=int(input()) n1=len(n) if len(n)<=k: print(0) sys.exit() a='' i=0 while i < (n1-1) and k>0: if int(n[i])>int(n[i+1]): i+=1 k-=1 continue else: a+=n[i] i+=1 a+=n[i] i+=1 if k>0: a=a[:-k] if i<=(n1-1): while i < n1: a+=n[i] i+=1 print(int(a)%((10**9)+7))
import java.util.*; class Main { public static void main (String[]args) { Scanner sc = new Scanner (System.in); String s = sc.nextLine (); int k = sc.nextInt (); int ans; System.out.println (smallestNumber (s, k) % (int) (1e9 + 7)); } static int smallestNumber (String num, int k) { if (num.length () <= k) return 0; HashMap < Character, Integer > pos = new HashMap <> (); for (int i = 0; i < num.length (); i++) { pos.put (num.charAt (i), i); } String temp = num; num = sortString (num); String ans = num.substring (0, num.length () - k); ArrayList < Integer > v = new ArrayList <> (); for (int i = 0; i < ans.length (); i++) { v.add (pos.get (ans.charAt (i))); } Collections.sort (v); String ret = ""; for (int i = 0; i < v.size (); i++) { ret += temp.charAt (v.get (i)); } int result = Integer.parseInt ("" + ret); return result; } public static String sortString (String inputString) { char tempArray[] = inputString.toCharArray (); Arrays.sort (tempArray); return new String (tempArray); } }
FAQs related to KPIT Coding Questions
Question 1: What is the KPIT test procedure?
KPIT Technologies usually conducts Online Assessments 0f 1 Hour 40 Minutes which include:
- Section 1: Aptitude
- Section 2: Technical Questions [Domain Specific ]
- Section 3: Professional Communication-related questions.
Question 2: How many rounds of interview are there in KPIT?
- There are 2 Rounds of Technical assessments including Programming in C, C++, Java, SQL, and DBMS.
- At last HR Interview.
Question 3: What is the salary package of KPIT?
On Average KPIT Technologies’ salary for a Software Engineer in India ranges between ₹ 4 – 6 Lakhs for less than 1 year of experience to 2 years.
Question 4: What KPIT company do?
KPIT Technologies is a company that works with the automotive and mobility industries to turn the concept of software-controlled vehicles into a reality.
It specializes in developing and integrating software, helping the automobile sector to get more advanced and intelligent.
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