Samsung Research
Paras Super Mart Interview Questions and Answers
Q1. Batch Photography Problem
Alex has acquired a machine that can photocopy photos in batches of a minimum size 'K'. Given 'N' photos with resolutions represented in an integer array photos
, the machine produces a...read more
Minimize maximum error by splitting photos into batches of size at least 'K'.
Sort the array of resolutions in ascending order.
Iterate through the array and calculate the error for each possible batch.
Return the minimum possible maximum error found.
Array Sum Calculation
Calculate the sum of all elements in an array of length N
.
Input:
Line 1: An integer N indicating the size of the array.
Line 2: N integers, the elements of the array, separated by spaces.
Calculate the sum of all elements in an array of length N.
Iterate through the array and add each element to a running sum.
Return the final sum as the output.
Q3. The Skyline Problem
Compute the skyline of given rectangular buildings in a 2D city, eliminating hidden lines and forming the outer contour of the silhouette when viewed from a distance. Each building is descri...read more
Compute the skyline of given rectangular buildings in a 2D city, eliminating hidden lines and forming the outer contour of the silhouette.
Iterate through the buildings and create a list of critical points (x, y) where the height changes.
Sort the critical points based on x-coordinate and process them to generate the skyline.
Merge consecutive horizontal segments of equal height to ensure no duplicates in the output.
Q4. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Sort an integer array containing only 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.
Iterate through the array and swap elements based on the values encountered.
Maintain left pointer for 0s, right pointer for 2s, and current pointer for traversal.
Example: If current element is 0, swap it with element at left pointer and increment both pointers.
Example: If current element is 2, swap it with element at r...read more
Q5. MergeSort Linked List Problem Statement
You are given a Singly Linked List of integers. Your task is to sort the list using the 'Merge Sort' algorithm.
Input:
The input consists of a single line containing the ...read more
Sort a Singly Linked List using Merge Sort algorithm.
Implement the Merge Sort algorithm for linked lists.
Divide the list into two halves, sort each half recursively, then merge them.
Use a fast and slow pointer to find the middle of the list for splitting.
Handle the base case of a single node or empty list.
Example: Input: 4 3 2 1 -1, Output: 1 2 3 4
Q6. Ninja and Alien Language Order Problem
An alien dropped its dictionary while visiting Earth. The Ninja wants to determine the order of characters used in the alien language, based on the given list of words fro...read more
Determine the order of characters in an alien language based on a list of words.
Create a graph where each character is a node and there is a directed edge from character 'a' to character 'b' if 'a' comes before 'b' in any word.
Perform a topological sort on the graph to get the order of characters.
Return the order as a string in lexicographical order.
Q7. Trie Implementation
Trie is a tree data structure used for efficient retrieval of key-value pairs.
Trie is also known as prefix tree.
Each node in a trie represents a single character of a key.
Trie is commonly used in autocomplete and spell checking algorithms.
Example: Inserting 'apple' and 'app' into a trie would result in a structure where 'app' is a prefix of 'apple'.
Q8. LRU Implementation
LRU (Least Recently Used) is a cache eviction policy that removes the least recently used items first.
LRU cache stores key-value pairs with a maximum capacity.
When the cache is full, the least recently used item is removed to make space for new items.
Each time a key is accessed, it is moved to the front of the cache to indicate it was recently used.
Interview Process at Paras Super Mart
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month