Chubb Coding Questions & Solutions 2025 | Chubb Coding Questions | Chubb Coding Questions and Answers | Chubb Interview Questions and Answers
Chubb Coding Questions & Solutions 2025: The job seekers are interested to searching the private jobs and off campus drive. The Chubb will be conducted the many coding interview rounds. Aspirants are willing to attend the Chubb Coding Interviews and aimed to get the Chubb Jobs. The Chubb Coding Interview will be intimated through mail. Candidates check the Mail to confirm the interview. The Chubb Coding Questions are asked well known programming languages like C, C++, Java, Python etc., Applicants start your preparation for the Chubb Coding Interview. Must know the Chubb Coding Questions with Answers/ Chubb Coding Interview Questions.
Candidates well prepare Chubb Coding Interview Questions and Answers. Those who will be qualified in the Chubb Coding Interview Round, they got the Chubb Jobs. Here we provide all programmes Coding Questions. Candidates use this page to download Chubb Coding Questions. Practice yourself with Chubb Coding Questions with Solutions. Make a schedule for the preparation and must practice through writing. This Chubb Coding Interview Questions is helping to crack the interview process easily. Candidates focused to prepare the zoho coding interview with the Chubb Coding Questions and answers.
Chubb Coding Questions and Answers
Q) Problem Statement -: A taxi can take multiple passengers to the railway station at the same time.On the way back to the starting point,the taxi driver may pick up additional passengers for his next trip to the airport.A map of passenger location has been created,represented as a square matrix.
The Matrix is filled with cells,and each cell will have an initial value as follows:
- A value greater than or equal to zero represents a path.
- A value equal to 1 represents a passenger.
- A value equal to -1 represents an obstruction.
The rules of motion of taxi are as follows:
- The Taxi driver starts at (0,0) and the railway station is at (n-1,n-1).Movement towards the railway station is right or down,through valid path cells.
- After reaching (n-1,n-1) the taxi driver travels back to (0,0) by travelling left or up through valid path cells.
- When passing through a path cell containing a passenger,the passenger is picked up.once the rider is picked up the cell becomes an empty path cell.
- If there is no valid path between (0,0) and (n-1,n-1),then no passenger can be picked.
- The goal is to collect as many passengers as possible so that the driver can maximize his earnings.
For example consider the following grid,
0 1
-1 0
Start at top left corner.Move right one collecting a passenger. Move down one to the destination.Cell (1,0) is blocked,So the return path is the reverse of the path to the airport.All Paths have been explored and one passenger is collected.
Returns:
Int : maximum number of passengers that can be collected.
Sample Input 0
4 -> size n = 4
4 -> size m = 4
0 0 0 1 -> mat
1 0 0 0
0 0 0 0
0 0 0 0
Output 0
2
Explanation 0
The driver can contain a maximum of 2 passengers by taking the following path (0,0) → (0,1) → (0,2) → (0,3) → (1,3) → (2,3) → (3,3) → (3,2) → (3,1) → (3,0) → (2,0) → (1,0) → (0,0)
Sample Input 1
STD IN Function
———— ————-
3 → size n=3
3 → size m=3
0 1 -1 → mat
1 0 -1
1 1 1
Sample Output 1
5
Explanation 1
The driver can contain a maximum of 5 passengers by taking the following path (0,0) → (0,1) → (1,1) → (2,1) → (2,2) → (2,1) → (2,0) → (1,0) → (0,0)
C++ PROGRAM
#include <bits/stdc++.h> using namespace std; int n, m; int mat[105][105]; map<pair<int, pair<int,="" int="">>, int> dp; bool isValid(int i, int j) { if (mat[i][j] == –1) return false; if (i < 0 || i >= n) return false; if (j < 0 || j >= m) return false; return true; } int solve(int i, int j, int x, int y) { if (!isValid(i, j)) { return INT_MIN; } if (!isValid(x, y)) { return INT_MIN; } if (i == n – 1 && x == n – 1 && j == m – 1 && y == m – 1) { if (mat[i][j] == 1) { return 1; } else { return 0; } } if (dp.find({i, {j, x}}) != dp.end()) return dp[{i, {j, x}}]; int cur = 0; if (i == x && j == y) { if (mat[i][j] == 1) cur = 1; } else { if (mat[i][j] == 1) cur++; if (mat[x][y] == 1) cur++; } int op1 = solve(i + 1, j, x + 1, y); int op2 = solve(i, j + 1, x, y + 1); int op3 = solve(i + 1, j, x, y + 1); int op4 = solve(i, j + 1, x + 1, y); int ans = cur + max(op1, max(op2, max(op3, op4))); return dp[{i, {j, x}}] = ans; } int main() { cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> mat[i][j]; int ans = solve(0, 0, 0, 0); if (ans >= 0) cout << solve(0, 0, 0, 0) << endl; else cout << –1 << endl; return 0; }</pair<int,>
JAVA PROGRAM
import java.util.*; class Solution { public static int cost(int grid[][], int row1, int col1,int row2, int col2) { if (row1 == row2 && col1 == col2) { if (grid[row1][col1] == 1) return 1; return 0; } int ans = 0; if (grid[row1][col1] == 1) ans++; if (grid[row2][col2] == 1) ans++; return ans; } public static int solve(int n, int m, int grid[][],int dp[][][], int row1,int col1, int row2) { int col2 = (row1 + col1) - (row2); if (row1 == n - 1 && col1 == m - 1 &&row2 == n - 1 && col2 == m - 1) return 0; if (row1 >= n || col1 >= m ||row2 >= n || col2 >= m) return -1 * Integer.MAX_VALUE; if (dp[row1][col1][row2] != -1) return dp[row1][col1][row2]; int ch1 = -1 * Integer.MAX_VALUE, ch2 = -1 * Integer.MAX_VALUE; int ch3 = -1 * Integer.MAX_VALUE, ch4 = -1 * Integer.MAX_VALUE; if (grid[row1][col1 + 1] != -1 && grid[row2 + 1][col2] != -1) ch1 = cost(grid, row1, col1 + 1, row2 + 1, col2) + solve(n, m, grid, dp, row1, col1 + 1, row2 + 1); if (grid[row1][col1 + 1] != -1 && grid[row2][col2 + 1] != -1) ch2 = cost(grid, row1, col1 + 1, row2, col2 + 1) +solve(n, m, grid, dp, row1, col1 + 1, row2); if (grid[row1 + 1][col1] != -1 && grid[row2][col2 + 1] != -1) ch3 = cost(grid, row1 + 1, col1, row2, col2 + 1) +solve(n, m, grid, dp, row1 + 1, col1, row2); if (grid[row1 + 1][col1] != -1 && grid[row2 + 1][col2] != -1) ch4 = cost(grid, row1 + 1, col1, row2 + 1, col2) +solve(n, m, grid, dp, row1 + 1, col1, row2 + 1); return dp[row1][col1][row2] = Math.max(ch1, Math.max(ch2, Math.max(ch3, ch4))); } public static void initializeDp(int dp[][][],int item) { for(int i=0;i<5;i++) { for(int j=0;j<5;j++) for(int k=0;k<5;k++) dp[i][j][k]=item; } } public static int collectMax(int n,int m,int grid[][]) { int ans=0; int dp[][][]=new int[6][6][6]; initializeDp(dp,-1); if (grid[n - 1][m - 1] == -1 || grid[0][0] == -1) ans = -1 * Integer.MAX_VALUE; if (grid[0][0] == 1) ans++; grid[0][0] = 0; if (grid[n - 1][m - 1] == 1) ans++; grid[n - 1][m - 1] = 0; ans += solve(n, m, grid, dp, 0, 0, 0); return Math.max(ans, 0); } public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int arr[][]=new int[n+1][m+1]; for(int i=0;i
Q) Problem Statement -: Street Lights are installed at every position along a 1-D road of length n. Locations[] (an array) represents the coverage limit of these lights. The ith light has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ) (Closed intervals). Initially all the lights are switched off. Find the minimum number of fountains that must be switched on to cover the road.
Example
n = 3
locations[] = {0, 2, 13}then
For position 1: locations[1] = 0, max((1 – 0),
1) to mini (1+0), 3) gives range = 1 to 1
For position 2: locations[2] = 2, max((2-2),
1) to min( (2+2), 3) gives range = 1 to 3
For position 3: locations[3] = 1, max( (3-1),
1) to min( (3+1), 3) gives range = 2 to 3
For the entire length of this road to be covered, only the light at position 2 needs to be activated.
Returns:
int : the minimum number of street lights that must be activated
Constraints :
- 1<_n<_ 10^5
- O<_locations[i] <_ mini (n,100) (where 1 <_1<_10^5)
Sample Input For Custom Testing :
3 ->locations[] size n = 3
1 ->locations[] [1, 1, 1]
1 ->Sample Output
Sample Output :
1
C++ PROGRAM
#include <bits/stdc++.h> #define ll long long using namespace std; bool compare(pair<int, int=""> A, pair<int, int=""> B) { if (A.first = B.first) return A.second < B.second; return A.first < B.first; } int solve(int location[], int n) { pair<int, int=""> range[n]; for (int i = 0; i < n; i++) { int id = i + 1; range[i].first = max(1, id – location[i]); range[i].second = min(n, id + location[i]); } sort(range, range + n, compare); int i = 0; int ans = 0; while (i < n) { pair<int, int=""> p = range[i]; ans++; while (i + 1 < n && range[i].first == range[i + 1].first) { p.second = max(p.second, range[i + 1].second); i++; } //cout<<p.second<<” “<<i<<endl;="" while="" (i="" <="" n="" &&="" range[i].second="" i++;="" cout<<p.second<<”="" }="" return="" ans;="" int="" main()="" {="" n;="" cin="">> n; int location[n]; for (int i = 0; i < n; i++) cin >> location[i]; cout << solve(location, n) << endl; return 0; }</p.second<<”></int,></int,></int,></int,> PYTHON PROGRAM
def Sort_Tuple(tup): # getting length of list of tuples lst = len(tup) for i in range(0, lst): for j in range(0, lst-i-1): if (tup[j][1] > tup[j + 1][1]): temp = tup[j] tup[j]= tup[j + 1] tup[j + 1]= temp return tup def solve(l,n): rang=[[0,0]for i in range(n)] #print(rang) for i in range(n): id=i+1 rang[i][0]=max(1,id-l[i]) rang[i][1]=min(n,id+l[i]) Sort_Tuple((rang)) i=0 ans=0 while ip[1]: break i+=1 return ans n=int(input()) l=[] for i in range(n): l.append(int(input())) print(solve(l,n)) JAVA PROGRAM
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Pair{ Integer a; Integer b; Pair(){ } Pair(Integer a,Integer b){ this.a=a; this.b=b; } public Integer getA() { return a; } public void setA(Integer a) { this.a = a; } public Integer getB() { return b; } public void setB(Integer b) { this.b = b; } } class SortingPair implements Comparator{ @Override public int compare(Pair o1, Pair o2) { if(o1.getA()==o2.getA()) { if(o1.getB() < o2.getB()) { return 1; }else { return 0; } } if(o1.getA()< o2.getA()) { return 1; }else { return 0; } } } public class Application2 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int location[]=new int[n]; for(int i=0;i< n;i++) { location[i]=sc.nextInt(); } System.out.println(solve(location,n)); } private static int solve(int[] location, int n) { Pair range[] = new Pair[n]; for(int i=0;i< n;i++) { int id=i+1; range[i] = new Pair(); range[i].setA(Math.max(1, id-location[i])); range[i].setB(Math.min(n, id+location[i])); } Arrays.sort(range,new SortingPair()); int i=0,ans=0; while(i< n) { Pair p=range[i]; ans++; while(i+1< n && range[i].getA()==range[i+1].getA()) { p.b=Math.max(p.getB(), range[i+1].getB()); i++; } while(i< n && range[i].getB()<=p.getB()) { i++; } } return ans; } }
Q) Problem Statement -: A company has a list of jobs to perform. Each job has a start time, end time and profit value. The manager has asked his employee Anirudh to pick jobs of his choice. Anirudh being greedy wants to select jobs for him in such a way that would maximize his earnings.
Given a list of jobs how many jobs and total earning are left for other employees once Anirudh
Picks jobs of his choice.
Note: Anirudh can perform only one job at a time.
Input format:
Each Job has 3 pieces of info – Start Time,End Time and Profit
The first line contains the number of Jobs for the day. Say ‘n’. So there will be ‘3n lines following as each job has 3 lines.
Each of the next ‘3n’ lines contains jobs in the following format:
-
- start_time
- end-time
- Profit
start-time and end-time are in HHMM 24HRS format i.e. 9am is 0900 and 9PM is 2100
Constraints
- The number of jobs in the day is less than 10000 i.e. 0<_n<_10000
- Start-time is always less than end time.
Output format :-
Program should return an array of 2 integers where 1st one is number of jobs left and earnings of other employees.
Sample Input 1 :
3
0900
1030
100
1000
1200
500
53
1100
1200
300
Sample Output 1:
2
400
Sample Explanation 1
Anirudh chooses 1000-1200 jobs. His earnings is 500. The 1st and 3rd jobs i.e. 0900-1030 and 1100-1200 respectively overlap with the 2nd jobs. But profit earned from them will be 400 only. Hence Anirudh chooses 2nd one. Remaining 2 Jobs & 400 cash for other employees.
Sample Input 2:
5
0805
0830
100
0835
0900
100
0905
0930
100
0935
1000
100
1005
1030
100
Sample output 2:
0
0
Sample Explanation 2:
Anirudh can work on all appointments as there are none overlapping. Hence 0 appointments and 0 earnings for other employees.
C++ PROGRAM
#include <bits/stdc++.h> using namespace std; class job { public: int st, ed, cost; }; int getTime(string s) { int hr = (s[0] – ‘0’) * 10 + (s[1] – ‘0’); int min = (s[2] – ‘0’) * 10 + (s[3] – ‘0’); return hr * 60 + min; } bool compare(job A, job B) { return A.ed < B.ed; } int searchJob(job arr[], int st, int ed, int key) { int ans = –1; while (st <= ed) { int mid = (st + ed) / 2; if (arr[mid].ed <= key) { ans = mid; st = mid + 1; } else { ed = mid – 1; } } return ans; } pair<int, int=""> solve(job arr[], int n) { int dp[n] = {0}; int numOfJobs[n] = {0}; dp[0] = arr[0].cost; numOfJobs[0] = 1; for (int i = 1; i < n; i++) { int cur = arr[i].cost; int num = 1; int idx = searchJob(arr, 0, i – 1, arr[i].st); if (idx != cur) { cur += dp[idx]; num += numOfJobs[idx]; } if (cur > dp[i – 1]) { dp[i] = cur; numOfJobs[i] = num; } else { dp[i] = dp[i – 1]; numOfJobs[i] = numOfJobs[i – 1]; } } return {numOfJobs[n – 1], dp[n – 1]}; } int main() { int n; cin >> n; job arr[n]; int cost; string st, ed; int total = 0; for (int i = 0; i < n; i++) { cin >> st >> ed >> cost; arr[i].st = getTime(st); arr[i].ed = getTime(ed); arr[i].cost = cost; total += cost; } sort(arr, arr + n, compare); pair<int, int=""> res = solve(arr, n); cout << n – res.first << endl; cout << total – res.second << endl; return 0; }</int,></int,> JAVA PROGRAM
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; class Job{ public Integer st; public Integer ed; public Integer cost; public Job() { super(); } public Job(Integer st, Integer ed, Integer cost) { super(); this.st = st; this.ed = ed; this.cost = cost; } } class Pair{ public Integer first; public Integer second; public Pair() { super(); } public Pair(Integer first, Integer second) { super(); this.first = first; this.second = second; } } class SortingJobs implements Comparator{ @Override public int compare(Job o1, Job o2) { if(o1.ed<o2.ed) {="" return="" 1;="" }else="" 0;="" }="" public="" class="" application3="" static="" void="" main(string[]="" args)="" scanner="" sc="new" scanner(system.in);="" int="" n="sc.nextInt();" job[]="" arr="new" job[n];="" cost;="" string="" st,ed;="" total="0;" for(int="" i="0;i<n;i++)" st="sc.next();" ed="sc.next();" if(st.length()<4)="" while(st.length()!="4)" st+="0" ;="" if(ed.length()<4)="" while(ed.length()!="4)" ed+="0" cost="sc.nextInt();" arr[i]="new" job();="" arr[i].st="getTime(st);" arr[i].ed="getTime(ed);" arr[i].cost="cost;" +="cost;" arrays.sort(arr,new="" sortingjobs());="" pair="" res="new" pair();="" if(res="=null)" system.out.println(0);="" system.out.println(n-res.first);="" system.out.println(total-res.second);="" private="" solve(job[]="" arr,="" n)="" if(n="=0)" null;="" dp[]="new" int[n];="" numofjobs[]="new" dp[i]="0;" numofjobs[i]="0;" dp[0]="arr[0].cost;" numofjobs[0]="1;" curr="arr[i].cost;" num="1;" idx="searchJob(arr,0,i-1,arr[i].st);" if(idx!="curr" &&="" idx!="-1)" curr+="dp[idx];" num+="numOfJobs[idx];" if(curr="">dp[i-1]) { dp[i]=curr; numOfJobs[i]=num; }else { dp[i]=dp[i-1]; numOfJobs[i]=numOfJobs[i-1]; } } return new Pair(numOfJobs[n-1],dp[n-1]); } private static int searchJob(Job[] arr, int st, int ed, int key) { int ans=-1; while(st<=ed) { int mid=(st+ed)/2; if(arr[mid].ed<=key) { ans=mid; st=mid+1; }else { ed=mid-1; } } return ans; } private static int getTime(String st) { int hr = (st.charAt(0)-'0')*10 + (st.charAt(1)-'0'); int min = (st.charAt(2)-'0')*10 + (st.charAt(3)-'0'); return hr*60 + min; } }</o2.ed)>
Q) Problem Statement -: You are given an array, You have to choose a contiguous subarray of length ‘k’, and find the minimum of that segment, return the maximum of those minimums.
Sample input 0
1 → Length of segment x =1
5 → size of space n = 5
1 → space = [ 1,2,3,1,2]
2
3
1
2
Sample output
3
Explanation
The subarrays of size x = 1 are [1],[2],[3],[1], and [2],Because each subarray only contains 1 element, each value is minimal with respect to the subarray it is in. The maximum of these values is 3. Therefore, the answer is 3
C++ PROGRAM
#include<bits/stdc++.h> using namespace std; vector arr; int prevmin=-1; int flag=0; int x,n,q; int sorting(int start,int end) { if(start+1==n) {start=0;end=end-n;} if(start==end) return arr[start]; return min(arr[start],sorting(start+1,end)); } int func(int start,int end) { if(flag==0) {flag++;return prevmin=sorting(start,end);} if(arr[start-1]==prevmin) return prevmin; return prevmin=(arr[end]<=prevmin)?prevmin:sorting(start,end); } int main() { cin>>x>>n; int ans=0; for(int i=0;i<n;i++) {cin="">>q;arr.push_back(q);} for(int i=0;i< n;i++) { ans=max(ans,func(i,i+x-1)); } cout<< ans; }</n;i++)> PYTHON PROGRAM
s=int(input()) n=int(input()) a=[] for i in range(n): a.append(int(input())) def min_in_segment(start,end,prev,s,prev_min): if s==1: return a[start] else: if prev==-1 or prev_min==-2: return min(a[start:end+1]) elif prev_min!=-2: if prev!=prev_min: if a[end] JAVA PROGRAM
import java.util.*; class DiskSpace { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); int n=sc.nextInt(); int arr[]=new int[n]; for(int i=0;i< n;i++) arr[i]=sc.nextInt(); int min=Integer.MAX_VALUE; int max=Integer.MIN_VALUE; for(int i=0;i<=n-x;i++) { min=Integer.MAX_VALUE; for(int j=i;j<(i+x);j++) min=Math.min(min,arr[j]); max=Math.max(min,max); } System.out.println(max); } }
Q) 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 :
5 → number of strings
Hello Good morning Welcome you
Sample output :
morning
Explanation:
- Hello → 5
- Good → 4
- Morning → 7
- Welcome → 7
- You → 3
First word that is picked by computer is morning
Sample input 2 :
3
Go to hell
Sample output 2:
Better luck next time
Explanation:
Here no word with odd length so computer confuses and gives better luck next time
JAVA PROGRAM
import java.util.*; public class OddLength { 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(); 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())="" temp="(String)itr.next();" if(temp.length()="">max) { res=temp; max=temp.length(); } } System.out.println(res); } } }</n;i++)></n;i++)> PYTHON PROGRAM
n=int(input()) sentence=input().split() length=[] for i in sentence: L=len(i) if L%2==1: length.append(len(i)) else: length.append(0) if max(length)==0: print("Better Luck next Time") else: print(sentence[length.index(max(length))])
Links for get Chubb Coding Questions with Solutions 2024
JOB ALERT ON INSTAGRAM | FOLLOW NOW>> |
JOB ALERT ON YOUR EMAIL DAILY | SUBSCRIBE NOW>> |
The Chubb Coding Questions and Answers is downloading easily and also prepare more conveniently in this page. Kindly watch Dailyrecruitment.in site for more information updates about jobs and Education.
Govt Jobs by Qualifications
Education & Vacancies | Salary | Apply Link |
---|---|---|
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 |