Add office photos
Engaged Employer

ShareChat

3.6
based on 597 Reviews
Video summary
Filter interviews by

Bajaj Allianz General Insurance Interview Questions and Answers

Updated 5 Feb 2024

Q1. Flood Fill Algorithm Task

Assist Ninja in altering the color of a specific region in his photo. Given the image as a 2D array where each pixel is a positive integer, update the color of a specified pixel and th...read more

Ans.

The Flood Fill Algorithm is used to change the color of a particular region in an image and all its adjacent same-colored pixels.

  • The image is represented as a 2D array of positive integers

  • The starting pixel and new color are given

  • Adjacent pixels are connected in up, down, left, or right directions

  • Diagonal pixels are not considered adjacent

  • Implement the Flood Fill Algorithm to replace the color of the given pixel and its adjacent same-colored pixels with the new color

  • Repeat th...read more

View 1 answer

Q2. Network Delay Time Problem Statement

Given a network of nodes numbered from 1 to 'N', and 'M' edges. Each edge is represented by three values (u, v, w) where 'u' and 'v' are nodes, and 'w' is an integer represe...read more

Ans.

Find the time it takes for a signal to travel from a given source node to all other nodes in a network.

  • Use Dijkstra's algorithm to find the shortest path from the source node to all other nodes.

  • Keep track of the minimum time taken to reach each node.

  • If it is impossible for the signal to reach all nodes, return -1.

Add your answer

Q3. Kruskal’s Minimum Spanning Tree Algorithm Problem Statement

You are given a connected undirected weighted graph. Your task is to determine the weight of the minimum spanning tree of this graph.

A minimum spanni...read more

Ans.

The task is to find the weight of the minimum spanning tree of a given connected undirected weighted graph.

  • Implement Kruskal's algorithm to find the minimum spanning tree

  • Use a disjoint set data structure to keep track of connected components

  • Sort the edges in non-decreasing order of their weights

  • Iterate through the sorted edges and add them to the minimum spanning tree if they don't create a cycle

  • Return the sum of weights of the edges in the minimum spanning tree

Add your answer

Q4. Merge Sort Problem Statement

You are given a sequence of numbers, ARR. Your task is to return a sorted sequence of ARR in non-descending order using the Merge Sort algorithm.

Explanation:

The Merge Sort algorit...read more

Ans.

The task is to implement the merge sort algorithm to sort a given sequence of numbers in non-descending order.

  • Merge sort is a divide and conquer algorithm that recursively divides the input array into two halves until the size becomes 1.

  • Then it merges the two sorted halves to produce a single sorted array.

  • The time complexity of merge sort is O(n log n), where n is the size of the input array.

  • The algorithm is efficient for large data sets and guarantees a stable sort.

  • The imple...read more

Add your answer
Discover Bajaj Allianz General Insurance interview dos and don'ts from real experiences

Q5. Flip Bit to Win Problem Statement

You are given a task to help ninjas maximize their practice area in a dense forest represented by a sequence of trees (1s) and empty places (0s) in the binary representation of...read more

Ans.

Given an integer, find the maximum number of consecutive ones by flipping one bit.

  • Iterate through the binary representation of the integer to find the longest sequence of ones.

  • Track the current sequence of ones and the previous sequence to determine the maximum length after flipping one bit.

  • Update the maximum length whenever a zero is encountered and keep track of the position of the zero for flipping.

  • Return the maximum length of consecutive ones after flipping one bit for ea...read more

Add your answer

Q6. Dice Throws Problem Statement

You are given D dice, each having F faces numbered from 1 to F. The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers e...read more

Ans.

The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers equals the given 'target' sum.

  • Use dynamic programming to solve the problem efficiently.

  • Create a 2D array to store the number of ways to achieve each sum with different number of dice.

  • Iterate through the dice and sum possibilities to fill up the array.

  • Return the result modulo 10^9 + 7.

  • Optimize the solution to use no more than O(S) extra space by using rolling arra...read more

Add your answer

Q7. Postfix to Prefix Conversion Problem

Ninja has been given a Postfix expression and requires assistance in converting it to a Prefix expression.

A Postfix expression is formatted such that the operator follows t...read more

Ans.

Convert Postfix expression to Prefix expression by reversing the Postfix expression and then traversing it from left to right.

  • Reverse the given Postfix expression

  • Traverse the reversed expression from left to right

  • If an operand is encountered, push it to the stack

  • If an operator is encountered, pop two operands from the stack and concatenate them with the operator in the prefix form

  • Push the resulting string back to the stack

  • Repeat until the entire expression is processed

Add your answer

Q8. Saving Money Problem Statement

Ninja is adventurous and loves traveling while being mindful of his expenses. Given a set of 'N' stations connected by 'M' trains, each train starting from station 'A' and reachin...read more

Ans.

Given a set of stations connected by trains, find the cheapest fare from a source to a destination with a maximum number of stops.

  • Iterate through all possible routes with up to 'K' stops using DFS or BFS.

  • Keep track of the cost for each route and return the minimum cost found.

  • If no route is found within the maximum stops, return -1.

  • Consider using a graph data structure to represent the stations and trains.

  • Handle multiple test cases by looping through each case.

Add your answer

Q9. Safe Nodes in the Graph

You are provided with a matrix/list called 'EDGES' representing 'E' edges of a directed graph with 'N' nodes. Starting from a node 'START', a character named Ninja walks along a directed...read more

Ans.

Find all safe nodes in a directed graph where Ninja stops at an end node in less than 'K' steps.

  • Create a graph using the provided edges.

  • Perform a depth-first search (DFS) starting from each node to check if it reaches an end node.

  • Keep track of visited nodes and end nodes to determine safe nodes.

  • Return the safe nodes in sorted order.

Add your answer

More about working at ShareChat

#3 Best Tech Startup - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Intern Interview Questions from Similar Companies

4.4
 • 30 Interview Questions
3.8
 • 21 Interview Questions
4.1
 • 12 Interview Questions
2.0
 • 11 Interview Questions
3.9
 • 10 Interview Questions
4.8
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter