Juspay Coding Questions & Solutions 2025, Get Juspay Coding Questions

Juspay Coding Questions & Solutions 2025 | Juspay Coding Questions | Juspay Coding Questions and Answers | Juspay Coding Interview Questions | juspay previous year coding questions

Juspay Coding Questions & Solutions 2025: The Coding test is containing many programming languages. This Coding Test Round is evaluating your programming Skills and Coding Knowledge. The selection process contains many levels of the test. Coding Test is one of the main difficulty parts in every private sector interviews. Every Candidates mainly focused on this Coding Test. In the Private Sector Company of JUSPAY is hiring eligible employees. Many of the eligible candidates are applied in the JUSPAY Careers. The Juspay will conducting the hiring test for each post. Here we provided the Common Juspay Coding Questions and Answers/ juspay previous year coding questions. Who are interested in the Juspay Hiring, they definitely prepare for the selection process.

The hiring process is containing Coding Interview Round. Juspay will mostly ask the Juspay Coding questions in the C, C++, Java, Python Program. Candidates thoroughly prepare for the Languages for Juspay Coding Interview. By solving the Juspay Coding Questions and Answers, you will clear the Coding Interview Round. Candidates must prepare for the Juspay Coding test. In this page you can get the Juspay Coding questions with Solutions, Juspay Coding questions, JUSPAY Coding Question and Answers etc.

Juspay Previous Year Coding Questions 

In this Juspay Coding Questions contains important questions and methods. Candidates use this Juspay Previous Year Coding Questions to get the tips for exam preparation. Continous practising with the Juspay Previous Year Questions with Answers gives more confident and strengthen for your examination. Also crack the examination with the 100% results. JUSPAY issued the Juspay Coding Questions/ Juspay Previous Year Coding Question with Answers. So candidates easily download Juspay  previous year questions without any issues.

Juspay Coding Questions and Answers 

Q1: 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 0.

  • A Star is represented as an asterisk [*=ascii decimal 42]
  • A Bar is represented as a Pipe [“|”=ascii decimal 124]

Example

s=’|**|*|’
n = 2
startIndex=[0,0] endIndex=[4,5]

  • For the first pair of indices (0,4) the substrings is “|**|*”  . There are 2 stars between a pair of bars
  • For the second pair of indices (0,5) 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 <= StartIndex[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 and endIndex. Each line i of the n subsequent lines contains an integer of startIndex. Each line i of the n subsequent lines contains an integer of endindex.

Sample Input

*|*|  → s=”*|*|”
1 → size of startindex[] and endIndex[] is 1.
0 → startindex = 0
2 → endindex = 2

Sample output:

0

Explanation :

The substring from index = 0 to index = 2 is “*|*” . there is no consecutive pair of bars in this string.

C++ Program 

#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
    string str;
    cin >> str;
    int n;
    cin >> n;
    vector<int> startIndex(n);
    vector<int> endIndex(n);
    for (int i = 0; i < n; i++) {
        cin >> startIndex[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> endIndex[i];
    }
    int len = str.length();
    vector<int> counter(len, -1);
    int count = 0;
    int lastIdx = -1;

    stack<int> st;
    for (int i = 0; i < len; i++) {
        char ch = str[i];
        if (ch == '|') {
            while (!st.empty()) {
                int idx = st.top();
                st.pop();
                counter[idx] = i;
            }
        }
        st.push(i);
    }

    vector<int> ansArr(n);
    for (int i = 0; i < n; i++) {
        int sIndex = startIndex[i];
        int eIndex = endIndex[i];
        int sCount = 0;
        if (str[sIndex] != '|')
            sIndex = counter[sIndex];
        if (sIndex == -1 || counter[sIndex] == -1) {
            ansArr[i] = 0;
            continue;
        }
        while (sIndex < eIndex) {
            int nextIdx = counter[sIndex];
            if ((nextIdx != -1) && (nextIdx <= eIndex))
            {
                sCount += nextIdx - sIndex - 1;
            }
            sIndex = nextIdx;
        }
        ansArr[i] = sCount;
    }

    for (int ele : ansArr) {
        cout << ele << " ";
    }
    cout << endl;

    return 0;
}

Java Program 

import java.util.*;

class Main
{
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        String str = scn.next();
        int n = scn.nextInt();
        int startIndex[] = new int[n];
        int endIndex[] = new int[n];
        for(int i = 0; i < n; i++)
        {
            startIndex[i] = scn.nextInt();
        }
        for(int i = 0; i < n; i++)
        {
            endIndex[i] = scn.nextInt();
        }
        int len = str.length();
        int counter[] = new int[len];
        int count = 0;
        int lastIdx = -1;
        
        Arrays.fill(counter, -1);
        Stack<Integer> st = new Stack<>();
        for(int i = 0; i < len; i++)
        {
            char ch = str.charAt(i);
            if(ch == '|')
            {
                while(!st.empty())
                {
                    int idx = st.pop();
                    counter[idx] = i;
                }
            }
            st.push(i);
        }
        
        int ansArr[] = new int[n];
        for(int i = 0; i < n; i++)
        {
            int sIndex = startIndex[i];
            int eIndex = endIndex[i];
            int sCount = 0;
            if(str.charAt(sIndex) != '|')
                sIndex = counter[sIndex];
            if(sIndex == -1 || counter[sIndex] == -1)
            {
                ansArr[i] = 0;
                continue;
            }
            while(sIndex < eIndex)
            {
                int nextIdx = counter[sIndex];
                if((nextIdx != -1) && (nextIdx <= eIndex))
                {
                    sCount += nextIdx - sIndex - 1;
                }
                sIndex = nextIdx;
            }
            ansArr[i] = sCount;
        }
        
        for(int ele : ansArr)
        {
            System.out.print(ele + " ");
        }
    }
}

Python Program

str = input()
n = int(input())
startIndex = []
endIndex = []
for i in range(n):
    startIndex.append(int(input()))
for i in range(n):
    endIndex.append(int(input()))

len_str = len(str)
counter = [-1] * len_str
count = 0
lastIdx = -1

st = []
for i in range(len_str):
    ch = str[i]
    if ch == '|':
        while st:
            idx = st.pop()
            counter[idx] = i
    st.append(i)

ansArr = []
for i in range(n):
    sIndex = startIndex[i]
    eIndex = endIndex[i]
    sCount = 0
    if str[sIndex] != '|':
        sIndex = counter[sIndex]
    if sIndex == -1 or counter[sIndex] == -1:
        ansArr.append(0)
        continue
    while sIndex < eIndex:
        nextIdx = counter[sIndex]
        if nextIdx != -1 and nextIdx <= eIndex:
            sCount += nextIdx - sIndex - 1
        sIndex = nextIdx
    ansArr.append(sCount)

for ele in ansArr:
    print(ele, end=" ")

Q2: 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 Stephan will have after drinking the bloods before the battle.

Note : 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:

  • 1 <= 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.

C++ Program

#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; 
}

Java Program 

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 subsetA=new ArrayList(); 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());
    }
  }
}

Python Program 
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))

Q3: The principal has a problem with repetitions. Everytime someone sends the same email twice he becomes angry and starts yelling. His personal assistant filters the mails so that all the unique mails are sent only once, and if there is someone sending the same mail again and again, he deletes them. Write a program which will see the list of roll numbers of the student and find how many emails are to be deleted.

Input Format:

  • First line takes n, which is the total no. of mails recieved.
  • Second line takes the n no. of email id as input./li>

Output Format:

Total no. of duplicate email id’s to be deleted.

Constraints:

  • 1 <= n <= 10^4

Sample input:

  • 6
  • 1 3 3 4 3 3

Sample output

  • 3
C++ Program 

#include<bits/stdc++.h>
using namespace std;
map<int,int> m;
int main()
{
    int n,a,ans=0;
    cin>>n;
    while(n--)
    {
        cin>>a;
        m[a]++;
        if(m[a]>1) ans++;
    }
    cout<<ans;
}

Java Program 

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    TreeSet list=new TreeSet<>();
    for(int i=0;i<n;i++)
      list.add(sc.nextInt()); 
    
    System.out.println(Math.abs(n-list.size()));
 }
}

Python Program 

def countDuplicate(numbers):
    c=0
    for i in set(numbers):
        if numbers.count(i)>1:
            c+=numbers.count(i)-1
    return c
    
n=int(input())
numbers=[]
numbers = list(map(int, input().split()))
print(countDuplicate(numbers))

Q4: 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”, “ab”, ”abc”, ”abcd”, ”abcde”, ”b”, ”bc”, ”bcd”, ”bcde”, ”c”, ”cd”, ”cde”, ”d”, ”de”, ”e”.
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 and then arranged in lexicographic order.

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 as per lexicographical order will be with the id dc. The lexicographical order for adbc will be :
a
ab
abd
abdc
b
bd
bdc
c
d
dc

C++ Program

#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s;
    cin>>s;
    char c = s[0];
    int j = 0;
    for(int i=1;i<s.length();i++)
    if(c<s[i]) {j=i;c=s[i];}
    cout<<s.substr(j,s.length()-j);
}
Java Program 

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));
}
}
Python Program 
s=input()
j=1
c=0
while j<len(s):
    if ord(s[c])<ord(s[j]):
        c=j
    j+=1
print(s[c:])

Q5: Raman was playing a game,  he starts with x coins. Now in every step, he wins and loses and he has to get the money or pay the money as needed. He came in contact with a psychic who can see the future and the Psychic predicted the outcomes after each step. Now Raman wants to start the game with the minimum wage where he doesn’t run out of money.  Help Raman to find what money he should start with. The only rule to keep playing is not going in a credit situation.

Input Format:

  • First line with n, number of steps in the game
  • Next n lines, n integers denoting outcomes of every game. Positive means winning and negative means losing that money.

Output Format:

  • One single integer denoting the minimum amount to start with

Constraints:

  • Number of steps<=10^9
  • -1000<=Money needed in each step<=1000

Sample Input:

4
2
-9
15
2

Sample Output:

7

Explanation:

If he starts with 7 rupees, then after steps : 7 ->9 -> 0-> 15 -> 17.

C++ Program 

#include<iostream> 
using namespace std;

int main() {
    int n; 
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int sum=0,ans=0;
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
        if(sum<1)
        {
            sum=-sum;
            ans+=sum;
            sum=0;
        }
    }
    cout<<ans<<endl;
}

Java Program 

import java.util.*;
public class Main
{
  public static void main(String[] args)
{
   Scanner sc=new Scanner(System.in);
   int n=sc.nextInt();
   int arr[]=new int[n];
  
   for(int i=0;i<n;i++) 
   arr[i]=sc.nextInt();
   int sum=0,ans=0;
   for(int i=0;i<n;i++)
    {
        sum+=arr[i];
        if(sum<1)
        {
            sum=-sum;
            ans+=sum;
            sum=0;
        }
    }
  System.out.println(ans);
}
}

Python Program 
n=int(input())
arr=[]
for i in range(n):
    arr.append(int(input()))
s,a=0,0
for i in arr:
    s=s+i   
    if(s<1):
        a=a+(-1*s) 
        s=0 
print(a)

Juspay Coding Interview Questions and Answers 

Kindly watch the dailyrecruitment.in site for more interview coding questions & answers and Interview questions etc., Here you can download Juspay Coding Questions and Answers easily.

JOB ALERT ON INSTAGRAM FOLLOW NOW>>
JOB ALERT ON YOUR EMAIL DAILY SUBSCRIBE NOW>>
 

Govt Jobs by Qualifications

Education & Vacancies Salary Apply Link
10th Pass Govt Jobs - 5,000 Vacancies Rs. 5,200 - 63,200 Apply Now
12th Pass Govt Jobs - 18,000+ Vacancies Rs. 5,200 - 92,300 Apply Now
ITI Pass Jobs - 3,500 Vacancies Rs. 5,200 - 35,000 Apply Now
Any Graduate Jobs - 19,100 Vacancies Rs. 5,200 - 92,300 Apply Now
Central Govt Jobs Rs. 5,200 - 17,000 Apply Now
Bank Jobs - 1,000 Vacancies Rs. 5,200 - 29,200 Apply Now
Diploma Jobs - 9,300 Vacancies Rs. 5,200 - 35,000 Apply Now
BTech/BE Jobs - 18,000 Vacancies Rs. 15,000 - 1,00,000 Apply Now
Data Entry Jobs - 1,300 Vacancies Rs. 5,200 - 29,200 Apply Now
Private Jobs Rs. 10,000 - 67,700 Apply Now