Paytm Coding Questions with Answers
Paytm Coding Questions with Solutions 2023
Paytm Coding Questions with Solutions on this page, will help you learn more about the coding aspect of the Paytm hackerrank test questions. It carries a big weight and is an elimination round.
Get all there is to know about Paytm recruiting procedures and code inquiries on this page. You’ll get comprehensive information about the Paytm hiring procedure, eligibility standards, and pay scale.
About Paytm
India’s top digital payment and financial services provider, Paytm, aims to attract customers and merchants to its platform by providing them with a range of payment use cases.
Customers and businesses can use Paytm as a payment gateway to make secure payments using credit cards, bank accounts, and other e-wallets. Other payment options offered by Paytm include cellphone recharges, bill payments, movie tickets, taxi, train, and aircraft tickets, loan payments, insurance, foreign exchange, and more.
Prime Course Trailer
Recruitment Process at Paytm
This article’s discussion of Paytm’s hiring procedure can assist you in comprehending the method used by Paytm to find applicants for the post of Software Development Engineer in Test (SDET) .
The aforementioned rounds are part of the Paytm hiring process.
- MCQ and Coding
- Virtual Interview 1
- Virtual Interview 2
We have even tabulated some more information for your reference and understanding.
EPAM | Related Information |
---|---|
Batch | 2023 |
Course | B.Tech (CSE, IT, ECE, EEE) |
Education |
|
Rounds |
|
Cost to Company (CTC) | 7.5 LPA |
Stipend | 8000/- |
Related Banners
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
Paytm Coding Questions with Answers
Question 1 : Guess the word
Problem Statement :
Kochouseph Chittilappilly went to Dhruv Zplanet , a gaming space, with his friends and played a game called “Guess the Word”.
Rules of games are –
Computer displays some strings on the screen and the player should pick one string / word if this word matches with the random word that the computer picks then the player is declared as Winner.
Kochouseph Chittilappilly’s friends played the game and no one won the game. This is Kochouseph Chittilappilly’s turn to play and he decided to must win the game.
What he observed from his friend’s game is that the computer is picking up the string whose length is odd and also that should be maximum. Due to system failure computers sometimes cannot generate odd length words. In such cases you will lose the game anyways and it displays “better luck next time”. He needs your help. Check below cases for better understand
Sample input 0:
5 → number of strings
Hello Good morning Welcome you
Sample output 0:
morning
Explanation:
Hello → 5
Good → 4
Morning → 7
Welcome → 7
You → 3
First word that is picked by computer is morning
Sample input 1:
3
Go to hell
Sample output 1:
Better luck next time
Explanation:
Here no word with odd length so computer confuses and gives better luck next time
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a, result = ""; while (n--) { cin >> a; if (a.length() & 1) if (a.length() > result.length()) result = a; } if (result == "") cout << "Better luck next time"; else cout << result; }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String arr[] = new String[n]; for (int i = 0; i < n; i++) arr[i] = sc.next(); int len = 0; ArrayList < String > oddLength = new ArrayList < String > (); for (int i = 0; i < n; i++) { len = arr[i].length(); if (len % 2 == 1) oddLength.add(arr[i]); } if (oddLength.size() == 0) System.out.println("Better luck next time"); else { Iterator itr = oddLength.iterator(); int max = -1; String res = ""; while (itr.hasNext()) { String temp = (String) itr.next(); if (temp.length() > max) { res = temp; max = temp.length(); } } System.out.println(res); } } }
n = int(input()) L = list(map(str, input().split())) result = "" for a in L: if len(a) & 1: if len(a) > len(result): result = a if result == "": result = "Better luck next time" print(result)
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 Main { 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())) 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 : Stars Between Bars
Problem statement :
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 :
int [n];each element[i] answers the query of startIndex[i] to endindex[i]
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 Case 0
Sample Input for Custom Testing
*|*| → 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 4 :Vampire Battle (R->Medium)
Problem statement :
Stephan is a vampire. And he is fighting with his brother Damon. Vampires get energy from human bloods, so they need to feed on human blood, killing the human beings. Stephan is also less inhuman, so he will like to take less life in his hand. Now all the people’s blood has some power, which increases the powers of the Vampire. Stephan just needs to be more powerful than Damon, killing the least human possible. Tell the total power Steohan will have after drinking the bloods before the battle.
Note that: Damon is a beast, so no human being will be left after Damon drinks everyone’s blood. But Stephan always comes early in the town.
Input Format :
First line with the number of people in the town, n.
Second line with a string with n characters, denoting the one digit power in every blood.
Output Format :
Total minimum power Stephan will gather before the battle.
Constraints :
n<=10^4
Sample input :
6
093212
Sample output:
9
Explanation :
Stephan riches the town, drinks the blood with power 9. Now Damon cannot reach 9 by drinking all the other bloods.
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, sum1 = 0; cin >> n; string s; cin >> s; sort(s.begin(), s.end(), greater < char > ()); for (auto i: s) sum += (i - '0'); for (auto i: s) { if (sum1 > sum) break; sum1 += (i - '0'); sum -= i - '0'; } cout << sum1; }
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String str = sc.next(); char arr[] = str.toCharArray(); int a[] = new int[arr.length]; for (int i = 0; i < a.length; i++) a[i] = Integer.parseInt(arr[i] + ""); Arrays.sort(a); int sum = 0; for (int i = 0; i < a.length; i++) sum = sum + a[i]; int sumA = 0; int sumB = sum; ArrayList < Integer > subsetA = new ArrayList < Integer > (); for (int i = a.length - 1; i >= 0; i--) { sumA = sumA + a[i]; sumB = sumB - a[i]; subsetA.add(a[i]); if (sumA > sumB) break; } Iterator itr = subsetA.iterator(); while (itr.hasNext()) { System.out.print((Integer) itr.next()); } } }
n = int(input()) ar = input() sorted(ar, reverse=True) br = [] s = 0 aa = [] for i in ar: aa.append(int(i)) su = sum(aa) while s <= su: s += aa[0] su = su - (aa[0]) br.append(aa.pop(0)) print(sum(br))
Question 5 :Devil Groups (R->Easy)
Problem statement :
There are some groups of devils and they splitted into people to kill them. Devils make People to them left as their group and at last the group with maximum length will be killed. Two types of devils are there namely “@” and “$”
People is represented as a string “P”
Input Format:
First line with the string for input
Output Format:
Number of groups that can be formed.
Constraints:
2<=Length of string<=10^9
Input string
PPPPPP@PPP@PP$PP
Output
7
Explanation
4 groups can be formed
PPPPPP@
PPP@
PP$
PP
Most people in the group lie in group 1 with 7 members.
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a = 0, mx = 0; for (int i = 0; i < s.length(); i++) { a++; if (s[i] == '@' || s[i] == '$') { mx = max(a, mx); a = 0; } } cout << mx; }
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); str = str.replace("@", " "); str = str.replace("$", " "); String arr[] = str.split(" "); int max = 0; for (int i = 0; i < arr.length; i++) max = Math.max(max, arr[i].length()); System.out.println(max + 1); } }
s = input() s = s.replace("@", " ").replace("$", " ") s = s.split() ans = [] for i in s: ans.append(len(i) + 1) ans[-1] -= 1 print(max(ans))
Paytm Coding Questions with Answers FAQ's
Question 1: What is the importance of Coding in Paytm Placement Exam?
Coding plays a crucial role in Paytm Placement Exam, it almost covers 50% of the test.
Question 2: Is Paytm exam difficult to crack?
Paytm exam is of High Difficulty. They put emphasis on theoretical and problem solving skills of the candidate.
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