20+ Ceasefire Industries Interview Questions and Answers
Q1. 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
The task is to find the cheapest price from the given source to destination with up to K stops.
Read the number of test cases
For each test case, read the number of stations and trains
Read the details of each train (source, destination, ticket price)
Read the source station, destination station, and maximum number of stops
Implement a graph data structure to represent the stations and trains
Use a modified version of Dijkstra's algorithm to find the cheapest price with up to K sto...read more
Q2. Longest Increasing Path in a 2D Matrix Problem Statement
Given a matrix of non-negative integers of size 'N x M', where 'N' and 'M' denote the number of rows and columns respectively, find the length of the lon...read more
The task is to find the length of the longest increasing path in a 2D matrix, where you can move in four directions: left, right, up, or down from each cell.
Traverse the matrix and for each cell, find the longest increasing path starting from that cell
Use dynamic programming to store the length of the longest increasing path for each cell
Recursively explore all four directions from each cell, checking if the next cell is greater than the current cell
Keep track of the maximum ...read more
Q3. Binary Tree Construction from Preorder and Inorder Traversal
The goal is to construct a binary tree from given preorder and inorder traversal lists of the tree nodes.
Example:
Input:
preorder = [1, 2, 4, 7, 3]
i...read more
The task is to construct a binary tree using the given inorder and preorder traversals.
Use the preorder traversal to determine the root of the binary tree
Use the inorder traversal to determine the left and right subtrees of the root
Recursively construct the left and right subtrees
Return the root node of the constructed binary tree
Q4. Combination Sum Problem Statement
Given an array of distinct positive integers ARR
and a non-negative integer 'B', find all unique combinations in the array where the sum is equal to 'B'. Numbers can be chosen ...read more
The task is to find all unique combinations in an array whose sum is equal to a given target sum.
Use backtracking to generate all possible combinations
Sort the array in non-decreasing order to ensure elements in each combination are in non-decreasing order
Start with an empty combination and iterate through the array, adding each element to the combination and recursively calling the function with the remaining sum
If the sum becomes zero, add the combination to the result
If th...read more
Q5. K Closest Points to Origin Problem Statement
Your house is located at the origin (0,0) of a 2-D plane. There are N
neighbors living at different points on the plane. Your goal is to visit exactly K
neighbors wh...read more
Q6. Longest Increasing Subsequence Problem Statement
Given an array of integers with 'N' elements, determine the length of the longest subsequence where each element is greater than the previous element. This subse...read more
Q7. Path Counting in Directed Graph
Given a directed graph with a specified number of vertices V
and edges E
, your task is to calculate the total number of distinct paths from a given source node S
to all other no...read more
Q8. Merging Accounts Problem
Given a list ACCOUNTS
where each element consists of a list of strings, with the first element being the name of the account holder, and the subsequent elements being the email addresse...read more
The task is to merge accounts belonging to the same person based on common emails and return the merged accounts.
Iterate through each account and create a mapping of emails to account holders
Iterate through the mapping and merge accounts with common emails
Sort the merged accounts and return the result
Q9. Search In Rotated Sorted Array Problem Statement
Given a rotated sorted array ARR
of size 'N' and an integer 'K', determine the index at which 'K' is present in the array.
Note:
1. If 'K' is not present in ARR,...read more
Q10. K - Sum Path In A Binary Tree
Given a binary tree where each node contains an integer value, and a value 'K', your task is to find all the paths in the binary tree such that the sum of the node values in each p...read more
The task is to print every path of a binary tree with the sum of nodes in the path as 'K'.
Traverse the binary tree and keep track of the current path and its sum
At each node, check if the sum of the current path equals 'K'
If yes, add the current path to the result
Continue traversing the left and right subtrees recursively
Remove the current node from the path before backtracking
Q11. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Q12. Roman Numeral to Integer Conversion
Convert a string representing a Roman numeral into its integer equivalent and return the result.
Explanation:
Roman numerals are represented by seven different symbols: I, V,...read more
Q13. Course Schedule II Problem Statement
You are provided with a number of courses 'N', some of which have prerequisites. There is a matrix named 'PREREQUISITES' of size 'M' x 2. This matrix indicates that for ever...read more
Q14. Merge Intervals Problem Statement
You are provided with 'N' intervals, each containing two integers denoting the start time and end time of the interval.
Your task is to merge all overlapping intervals and retu...read more
Q15. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Q16. Power Set Generation
Given a sorted array of 'N' integers, your task is to generate the power set for this array. Each subset of this power set should be individually sorted.
A power set of a set 'ARR' is the s...read more
Q17. Rank from Stream Problem Statement
Given an array of integers ARR
and an integer K
, determine the rank of the element ARR[K]
.
Explanation:
The rank of any element in ARR
is defined as the number of elements sma...read more
Q18. Longest Route Problem Statement
Given a 2-dimensional binary matrix called Mat
of size N x M that consists solely of 0s and 1s, find the length of the longest path from a specified source cell to a destination ...read more
Q19. Remove Duplicates from Sorted Array Problem Statement
You are given a sorted integer array ARR
of size N
. Your task is to remove the duplicates in such a way that each element appears only once. The output shou...read more
Q20. Arithmetic Expression Evaluation Problem Statement
You are provided with a string expression
consisting of characters '+', '-', '*', '/', '(', ')' and digits '0' to '9', representing an arithmetic expression in...read more
Facebook stores likes/dislikes using a combination of databases and caching systems.
Likes/dislikes are stored in a distributed database system like Cassandra or HBase.
Each like/dislike is associated with a user and the content being liked/disliked.
The database is sharded to handle the large volume of likes/dislikes.
Caching systems like Memcached or Redis are used to improve read performance.
Likes/dislikes can be stored as separate entities or as counters depending on the use ...read more
Facebook implements graph search by indexing user connections and content to enable efficient search queries.
Facebook indexes user connections and content to build a graph database.
The graph database is used to store and retrieve information about users, their relationships, and their content.
Graph search queries are executed by traversing the graph database to find relevant connections and content.
Facebook uses various algorithms and optimizations to improve the efficiency a...read more
Facebook Chat is a real-time messaging system that allows users to send and receive instant messages.
Facebook Chat uses a client-server architecture.
It utilizes long polling or WebSockets for real-time communication.
Messages are stored in a message queue for delivery.
Chat messages are encrypted for security.
Facebook Chat supports features like read receipts, typing indicators, and group chats.
Demand paging is a memory management technique where pages are loaded into memory only when needed.
Demand paging allows for efficient memory utilization by loading pages into memory on demand.
It reduces the amount of initial memory required to start a process.
When a page is needed but not in memory, a page fault occurs and the required page is loaded from disk.
Demand paging allows for larger virtual memory space than physical memory.
Examples of demand paging systems include W...read more
Interview Process at Ceasefire Industries
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month