Maersk
Haribhakti & Co Interview Questions and Answers
Q1. Sort 0s, 1s, and 2s Problem Statement
You are provided with an integer array/list ARR
of size 'N' which consists solely of 0s, 1s, and 2s. Your task is to write a solution to sort this array/list.
Input:
The fi...read more
Sort an array of 0s, 1s, and 2s in linear time with a single scan approach.
Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.
Iterate through the array once and swap elements based on their values and the pointers.
After the single scan, the array will be sorted in place with 0s, 1s, and 2s in order.
Q2. Fourth Largest Element in the Array
Given an array consisting of integers, your task is to determine the fourth largest element in the array. If the array does not contain at least four distinct elements, retur...read more
Find the fourth largest element in an array, return -2147483648 if not enough distinct elements.
Sort the array in descending order
Return the fourth element if it exists, else return -2147483648
Q3. Binary Tree Node Presence Problem
Determine if a node with a given integer value X exists in a specified binary tree.
Input:
The first line of each test case contains the binary tree nodes in level order sequen...read more
Check if a node with a given value exists in a binary tree.
Traverse the binary tree using depth-first search (DFS) or breadth-first search (BFS) to search for the node with the given value.
Use a recursive or iterative approach to implement the search algorithm.
Return 'true' if the node with the given value is found, otherwise return 'false'.
Q4. Shortest Path in an Unweighted Graph
The city of Ninjaland is represented as an unweighted graph with houses and roads. There are 'N' houses numbered 1 to 'N', connected by 'M' bidirectional roads. A road conne...read more
Find the shortest path in an unweighted graph from house 'S' to house 'T'.
Use Breadth First Search (BFS) algorithm to find the shortest path in an unweighted graph.
Create a queue to store the current house and its neighbors, and a visited set to keep track of visited houses.
Start BFS from house 'S' and stop when reaching house 'T'.
Return the path from 'S' to 'T' once 'T' is reached.
If multiple shortest paths exist, return any one of them.
Q5. Remove Duplicates Problem Statement
You are given an array of integers. The task is to remove all duplicate elements and return the array while maintaining the order in which the elements were provided.
Example...read more
Remove duplicates from an array while maintaining order.
Use a set to keep track of unique elements.
Iterate through the array and add elements to the set if not already present.
Convert the set back to an array to maintain order.
SQL joins are used to combine rows from two or more tables based on a related column between them.
Inner Join: Returns rows when there is at least one match in both tables.
Left Join: Returns all rows from the left table and the matched rows from the right table.
Right Join: Returns all rows from the right table and the matched rows from the left table.
Full Outer Join: Returns rows when there is a match in one of the tables.
Cross Join: Returns the Cartesian product of the two ta...read more
Q7. What is decorator in python
Decorator in Python is a design pattern that allows adding new functionality to an existing object without modifying its structure.
Decorators are functions that take another function as an argument and extend its behavior without explicitly modifying it.
They are commonly used to add logging, timing, caching, or authentication to functions.
Syntax for using decorators in Python involves using the @ symbol followed by the decorator function name above the function definition.
Exa...read more
Q8. What is yeild in python
yield is a keyword in Python used in generator functions to return a value without terminating the function
yield is used in generator functions to produce a series of values over time
When a generator function is called, it returns an iterator object but does not start execution immediately
Each time the yield statement is reached, the function's state is saved, and the value is returned to the caller
Execution of the function is paused until the next call to the generator's __n...read more
Q9. Architecture of current project
The current project follows a microservices architecture.
The project is divided into multiple small services that communicate with each other through APIs.
Each service is responsible for a specific functionality.
The services are deployed independently and can be scaled as per the demand.
The project uses Docker containers for easy deployment and management.
The communication between services is secured using HTTPS protocol.
The project uses a message broker for asynchronous comm...read more
More about working at Maersk
Interview Process at Haribhakti & Co
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month