Josh Technology Group
30+ Consilium Safety Interview Questions and Answers
Q1. Longest Alternating Subsequence Problem
Given an array ARR
of integers, determine the length of the longest alternating subsequence.
Input:
ARR = {Array elements}
Output:
Length of the longest alternating subse...read more
Q2. Buy and Sell Stock Problem Statement
Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more
Q3. Multiply Linked Lists Problem Statement
Your task is to multiply two numbers represented as linked lists and return the resultant multiplied linked list.
Explanation:
The multiplied list should be a linked list...read more
Q4. Add Two Numbers Represented by Linked Lists
Your task is to find the sum list of two numbers represented by linked lists and return the head of the sum list.
Explanation:
The sum list should be a linked list re...read more
Q5. Closest Leaf in a Binary Tree
Ninja is stuck in a maze represented as a binary tree, and he is at a specific node ‘X’. Help Ninja find the shortest path to the nearest leaf node, which is considered an exit poi...read more
Q6. Minimum Jumps Problem Statement
Bob and his wife are in the famous 'Arcade' mall in the city of Berland. This mall has a unique way of moving between shops using trampolines. Each shop is laid out in a straight...read more
Q7. Spiral Matrix Problem Statement
Given a two-dimensional matrix of integers, print the matrix in a spiral order.
Input:
The first line contains an integer 't' indicating the number of test cases. For each test c...read more
Q8. Flatten Binary Tree to Linked List
Transform a binary tree with integer values into a linked list by ensuring the linked list's nodes follow the pre-order traversal order of the binary tree.
Explanation:
Utiliz...read more
Q9. Maximum Non-Adjacent Subsequence Sum
Given an array of integers, determine the maximum sum of a subsequence without choosing adjacent elements in the original array.
Input:
The first line consists of an integer...read more
Q10. Divide Chocolates Problem Statement
Ninja bought chocolate consisting of several chunks, and the sweetness of each chunk is represented in an array ARR
. He wants to divide the chocolate into K + 1
parts (cuts),...read more
Q11. Covid Vaccination Distribution Problem
As the Government ramps up vaccination drives to combat the second wave of Covid-19, you are tasked with helping plan an effective vaccination schedule. Your goal is to ma...read more
Q12. Sum Root to Leaf Numbers
You are given an arbitrary binary tree consisting of N nodes, each associated with an integer value from 1 to 9. Each root-to-leaf path can be considered a number formed by concatenatin...read more
Q13. Binary Tree Diameter Problem Statement
Given a binary tree, determine the length of its diameter. The diameter is defined as the longest path between any two end nodes in the tree. The path's length is represen...read more
Q14. Is Height Balanced Binary Tree Problem Statement
Determine if the given binary tree is height-balanced. A tree is considered height-balanced when:
- The left subtree is balanced.
- The right subtree is balanced.
- T...read more
Q15. N Queens Problem
Given an integer N
, find all possible placements of N
queens on an N x N
chessboard such that no two queens threaten each other.
Explanation:
A queen can attack another queen if they are in the...read more
Q16. Rearrange Linked List Problem Statement
Given a singly linked list in the form 'L1' -> 'L2' -> 'L3' -> ... 'Ln', your task is to rearrange the nodes to the form 'L1' -> 'Ln' -> 'L2' -> 'Ln-1', etc. You must not...read more
Q17. Equilibrium Indices in a Sequence
You are given an array/list named 'SEQUENCE', which consists of 'N' integers. The task is to identify all equilibrium indices in this sequence.
Explanation:
An equilibrium inde...read more
Q18. Nuts and Bolts Problem
You are given a collection of 'N' nuts and 'N' bolts, each having unique sizes. Your objective is to match each nut with its corresponding bolt based on size, adhering to a one-to-one map...read more
Q19. Zig-Zag Array Rearrangement
You are provided with an array of distinct elements, and your task is to rearrange the array elements in a zig-zag manner. Specifically, for every odd index i
, the element ARR[i]
sho...read more
Q20. Reverse Linked List in K-Groups
Given a linked list consisting of 'N' nodes and an integer 'K', reverse the linked list in groups of size K. Specifically, reverse the nodes in each group starting from (1, K), (...read more
Q21. Merge Two Binary Trees Problem Statement
You are given the roots of two binary trees, root1
and root2
. Merge these two trees into a new binary tree. If two nodes overlap, sum the node values as the new node val...read more
Q22. Reverse Linked List in Groups of K
You are provided with a linked list containing 'N' nodes and an integer 'K'. The task is to reverse the linked list in groups of size K, which means reversing the nodes in eac...read more
Q23. Nodes at Distance K from a Given Node
Given an arbitrary binary tree, a specified node within the tree, and an integer 'K', find all nodes that are exactly 'K' distance away from the specified node. Return a li...read more
Q24. Spiral Matrix Path Problem Statement
Given a N x M matrix of integers, print the spiral order of the matrix.
Input:
The input starts with an integer 'T' representing the number of test cases. Each test case con...read more
Q25. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Q26. Kth Ancestor in a Binary Tree
You are given an arbitrary binary tree consisting of N
nodes numbered from 1 to N
, an integer K
, and a node TARGET_NODE_VAL
from the tree. Your task is to find the Kth ancestor of ...read more
Q27. Find Nodes at Distance K in a Binary Tree
Your task is to find all nodes that are exactly a distance K from a given node in an arbitrary binary tree. The distance is defined as the number of edges between nodes...read more
Q28. Replace with Sum of Greater Nodes Problem Statement
Convert a given binary search tree (BST) with 'N' nodes into a Greater Tree. In the Greater Tree, each node's data should be updated to the sum of its origina...read more
Q29. Rotate Matrix K Times Problem Statement
Given a matrix, rotate its elements clockwise by 90 degrees, K times.
Each rotation by 90 degrees counts as one.
Input:
Line 1: Two integers M and N, denoting the number ...read more
Q30. Remove BST Keys Outside Given Range
Given a Binary Search Tree (BST) and a specified range [min, max], your task is to remove all keys from the BST that fall outside this range. The BST should remain valid afte...read more
Q31. Sum Root to Leaf Path Problem
You are given an arbitrary binary tree consisting of N
nodes where each node is associated with an integer value from 1 to 9. Each root-to-leaf path in the tree represents a number...read more
Q32. Dijkstra's Shortest Path Problem Statement
You are given an undirected graph with V
vertices (numbered from 0 to V-1) and E
edges. Each edge connects two nodes u
and v
and has an associated weight representing ...read more
Q33. Binary Tree Level Order Traversal
You are given a binary tree of integers. Your task is to return the level order traversal of the given tree.
Input:
The first line contains an integer 'T', representing the num...read more
Q34. 0/1 Knapsack Problem Statement
A thief is planning to rob a store and can carry a maximum weight of 'W' in his knapsack. The store contains 'N' items where the ith item has a weight of 'wi' and a value of 'vi'....read more
Q35. Dijkstra's Shortest Path Problem
Given an undirected graph with ‘V’ vertices (labeled 0, 1, ... , V-1) and ‘E’ edges, where each edge has a weight representing the distance between two connected nodes (X, Y).
Y...read more
Top HR Questions asked in Consilium Safety
Interview Process at Consilium Safety
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month