Zoho Coding Questions With Answers 2024 (FAQ): Expected, Previous Questions, & More

Zoho Coding Questions With Answers 2024 | Zoho Coding Questions in Java | Zoho Coding Questions With Answers in Python | Zoho Coding Questions in C | Zoho Coding Questions With Answers PDF 

Zoho Coding Questions With Answers 2024 | Zoho Coding Questions: The Zoho Coding Questions combine every essential algorithm, data structure, and programming concept. We can help if you want to work at Zoho and are unsure of how to get ready for the questions in the Zoho Coding Round. One of the most important portions of the Zoho test is the coding round. We discussed various sample Zoho Coding rounds and possible answers in this blog. In this article, we will discuss Zoho Coding Questions. Zoho provides a special method for evaluating a candidate’s problem-solving abilities. They often host coding competitions on their blog. If you complete the challenge successfully, you could be asked for an interview. You will learn all there is to know about Zoho in this post. To get more Private Jobs, click here

ZOHO PREPARATION LINKS
Zoho Aptitude Questions with Answers Zoho Previous Year Question Papers with Answers
Zoho On-Campus Coding Questions and Answers 2024 Zoho Interview Questions With Answers 2024
Zoho Computer Programming Questions and Answers ZOHO Advanced Programming Round Questions and Answers 
Zoho Salary Structure in Chennai Area Zoho Aptitude Questions with Answers 2024
Zoho Aptitude Syllabus & Pattern

Zoho Coding Questions and Answers 2024

Question: Parallel Columbus

Problem Statement: Nobel Prize-winning Austrian-Irish physicist Erwin Schrödinger developed a machine and brought as many Christopher Columbus from as many parallel universes he could. Actually he was quite amused by the fact that Columbus tried to find India and got America. He planned to dig it further.

Though totally for research purposes, he made a grid of size n X m, and planted some people of America in a position (x,y) [in 1 based indexing of the grid], and then planted you with some of your friends in the (n,m) position of the grid. Now he gathered all the Columbus in 1,1 positions and started a race.

Given the values for n, m, x, y, you have to tell how many different Columbus(s) together will explore you as India for the first time.

Remember, the Columbus who will reach to the people of America, will be thinking that as India and hence wont come further.

Function Description:

Complete the markgame function in the editor below. It has the following parameter(s):

Parameters:

Name Type Description
n Integer The number of rows in the grid.
m Integer The number of columns in the grid.
x Integer The American cell’s Row.
y Integer The American cell’s Column.

Constraints:

  • 1 <= n <= 10^2
  • 1 <= m <= 10^2
  • 1 <= x <= n
  • 1 <= y <= m

Input Format:

  • The first line contains an integer, n, denoting the number of rows in the grid.
  • The next line contains an integer m, denoting the number of columns in the grid.
  • The next line contains an integer, x, denoting the American cell’s row.
  • The next line contains an integer, y, denoting the American cell’s column.

Sample Cases

Sample Input 1

2

2

2

1

Sample Output 1

1

Explanation

The only way possible is (1,1) ->(2,1) -> (2,2), so the answer is 1.

C++ PROGRAM

#include <bits/stdc++.h>
using namespace std;
unordered_map<int,long long int> f;
 
long long int Fact(int n)
{
  if(f[n]) return f[n];
  return f[n]=n*Fact(n-1);
}
 
int main()
{
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  n-=1;m-=1;x-=1;y-=1;
  f[0]=f[1]=1;
  int p=(Fact(m+n)/(Fact(m)*Fact(n)));
  int imp=((Fact(x+y)/(Fact(x)*Fact(y)))*(Fact(m-x+n-y)/(Fact(m-x)*Fact(n-y))));
  cout<<p-imp;
}

PYTHON PROGRAM

import math
n=int(input())-1
m=int(input())-1
x=int(input())-1
y=int(input())-1

ans=math.factorial(n+m)
ans=ans//(math.factorial(n))
ans=ans//(math.factorial(m))

ans1=math.factorial(x+y)
ans1=ans1//(math.factorial(x))
ans1=ans1//(math.factorial(y))

x1=n-x
y1=m-y

ans2=math.factorial(x1+y1)
ans2=ans2//(math.factorial(x1))
ans2=ans2//(math.factorial(y1))
print(ans-(ans1*ans2))

Question: Amusement Park

Problem Statement: Aashay 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.

They will give some k turns to remove the cost of one ticket where the cost of tickets are combined and given as string. Help Aashay in coding as he is not good in programming and get a 50%  discount for your ticket.

Constraints:

  • 1 <= number of tickets <= 10^5
  • 1 <= K <= number of tickets

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
    3
  • Sample Output 1
    0

C++ PROGRAM

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

PYTHON PROGRAM

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

Question: 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.

C++ PROGRAM

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, ans =0,sum=0;
    cin>>n;
    vector<int> 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<int>());
    for(int i=0;i<n;i++)
    {
        sum+=arr2[i];
        if(sum<0)
        {ans+=abs(sum);sum=0;}
    }
    cout<<ans;
}

PYTHON PROGRAM

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)

Q) You have been given a string S of length N. The given string is a binary string that consists of only 0’s and ‘1’s. Ugliness of a string is defined as the decimal number that this binary string represents.

 Example:

  • “101” represents 5.
  • “0000” represents 0.
  • “01010” represents 10.

There are two types of operations that can be performed on the given string.

  • Swap any two characters by paying a cost of A coins.
  • Flip any character by paying a cost of B coins
  • flipping a character means converting a ‘1’to a ‘0’or converting a ‘0’ to a ‘1’.

Initially, you have been given coins equal to the value defined in CASH. Your task is to minimize the ugliness of the string by performing the above mentioned operations on it. Since the answer can be very large, return the answer modulo 10^9+7.

Note:

  • You can perform an operation only if you have enough number of coins to perform it.
  • After every operation the number of coins get deducted by the cost for that operation.

Input Format

  • The first line contains an integer, N, denoting the number of character in the string
  • The next line contains a string, S, denoting the the binary string
  • The next line contains an integer, CASH, denoting the total number of coins present initially
  • Next will contains an integer, A, denoting the cost to swap two characters.
  • Then the next line contains an integer, B, denoting the cost to flip a character.

Constraints

  • 1 <= N <= 10^5
  • 1< len(S)<= 10^5
  • 1<=CASH <=10^5
  • 1<=A<=10^5
  • 1<=B<=10^5

Sample Input 1 :

4
1111
7
1
2

  Sample Output 1 :

1

  Explanation:

3 flips can be used to create “0001” which represents 1.

  Sample Input 2:

6
111011
7
1
3

  Sample Output 2:

7

  Explanation:

First swap 0 with the most significant 1, then use flip twice first on index one and then on index two “111011”=>”0111111″=>”001111″=>”000111″ the value represented is 7.

  Sample Input 3:

6
111011
7
3
2

  Sample Output 3:

3

 Explanation:

Flip the 3 most significant characters to get “000011” : the value represented by this string is 3.N

EXAMPLE PROGRAMS

C++ PROGRAM

#include<bits/stdc++.h>
using namespace std;
string s;
int n, cash, a, b;

void swapf ()
{
  int i;

  for (int a = 0; a < s.length (); a++) 
  if (s[a] == '1') 
  { 
      i = a; 
      break; 
      
  } 
  int j = s.length () - 1; 
  while (j > i)
    {
      if (cash < a)
	break;

      if (s[j] == '0')
	{
	  if (s[i] == '0')
	    i++;

	  else
	    {
	      swap (s[i], s[j]);
	      cash -= a;
	      j--;
	    }
	}
      else
	j--;
    }
}
void flipf ()
{
  int i;
  for (int a = 0; a < s.length (); a++) 
  if (s[a] == '1') 
  { 
      i = a; break; 
      
  } 
  while (cash >= b)
    {

      if (i == s.length ())
      break;

      if (s[i] == '1')
	{
	  s[i] = '0';
	  i++;
	  cash -= b;
	}
    }
}

int main ()
{
  cin >> n >> s >> cash >> a >> b;

  if (a < b)
    {
      swapf ();
      flipf ();
    }

  else
    {
      flipf ();
      swapf ();
    }

  cout << stoull (s, 0, 2);

}

JAVA PROGRAM

import java.util.*;
class Main
{
  static String str;
  static int cash, n, a, b;
  static void swapf ()
  {
    char s[] = str.toCharArray ();
    int i = 0;
    for (int a = 0; a < s.length; a++)
      if (s[a] == '1')
	{
	  i = a;
	  break;
	}
    int j = s.length - 1;
    while (j > i)
      {
	if (cash < a)
	  break;
	if (s[j] == '0')
	  {
	    if (s[i] == '0')
	      i++;
	    else
	      {
		char temp = s[i];
		s[i] = s[j];
		s[j] = temp;
		cash -= a;
		j--;
	      }
	  }
	else
	  j--;
      }
    str = new String (s);
  }
  static void flipf ()
  {
    char s[] = str.toCharArray ();
    int i = 0;

    for (int a = 0; a < s.length; a++)
      if (s[a] == '1')
	{
	  i = a;
	  break;
	}
    while (cash >= b)
      {
	if (i == s.length)
	  break;
	if (s[i] == '1')
	  {
	    s[i] = '0';
	    i++;
	    cash -= b;
	  }
      }
    str = new String (s);
  }

  public static void main (String[]args)
  {
    Scanner sc = new Scanner (System.in);
    n = sc.nextInt ();
    str = sc.next ();
    cash = sc.nextInt ();
    a = sc.nextInt ();
    b = sc.nextInt ();

    if (a < b)
      {
	swapf ();
	flipf ();
      }
    else
      {
	flipf ();
	swapf ();
      }
    System.out.println (Integer.parseInt (str, 2));
  }
}

Q): While playing an RPG game, you were assigned to complete one of the hardest quests in this game. There are monsters you’ll need to defeat in this quest. Each monster is described with two integer numbers – poweri and bonusi. To defeat this monster, you’ll need at least poweri experience points. If you try fighting this monster without having enough experience points, you lose immediately. You will also gain bonusi experience points if you defeat this monster. You can defeat monsters in any order.

The quest turned out to be very hard – you try to defeat the monsters but keep losing repeatedly. Your friend told you that this quest is impossible to complete. Knowing that, you’re interested, what is the maximum possible number of monsters you can defeat?

Input:

  • The first line contains an integer, n, denoting the number of monsters. The next line contains an integer, e, denoting your initial experience.
  • Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer, poweri, which represents power of the corresponding monster.
  • Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer, bonusi, which represents bonus for defeating the corresponding monster.

Output

  • 2

Example Programs:

JAVA PROGRAM

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main
{
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int exp = s.nextInt();

        int monst[] = new int[n];
        int bonus[] = new int[n];

        for (int i = 0; i < n; i++) {
            monst[i] = s.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bonus[i] = s.nextInt();
        }

        class Monster {
            private final int power, bonus;
            public Monster(int power, int bonus){
                this.power = power;
                this.bonus = bonus;
            }
        }

        Monster[] monsters = new Monster[n];

        for(int i = 0; i < n; i++)
            monsters[i] = new Monster(monst[i], bonus[i]);

        Arrays.sort(monsters, Comparator.comparingInt(m -> m.power));

        int count = 0;

        for(Monster m: monsters){
            if(exp < m.power) break;
            exp += m.bonus;
            ++count;
        }
        System.out.println(count);
    }
}
n = int(input())
lev = int(input())
p = []
b = []
a = []
ans = 0
for i in range(n):
   p.append(int(input()))
for j in range(n):
   b.append(int(input()))
for k in range(n):
   a.append([p[k], b[k]])
a.sort()
for z in a:
   if z[0] > lev:
       break
   lev += z[1]
   ans += 1
print(ans)

***BEST OFF LUCK***

We hope our article is informative. To stay ahead of the ever-increasing competition, you are strongly encouraged to download the previous year’s papers and start practicing. By solving these papers you will increase your speed and accuracy. For more information check Naukrimessenger.com website for exam patterns, syllabi, Results, cut-off marks, answer keys, best books, and more to help you crack your exam preparation. You can also take advantage of amazing Job offers to improve your preparation volume by joining in Telegram Channel page!!!