Groww
10+ Vega Conveyors & Automation Interview Questions and Answers
Q1. Minimum and Maximum Candy Cost Problem
Ram is in Ninjaland, visiting a unique candy store offering 'N' candies each with different costs. The store has a special offer: for every candy you purchase, you can tak...read more
Determine the minimum and maximum amounts of money needed to purchase all candies with a special offer.
Iterate through the candy costs array to find the minimum and maximum costs.
Consider the special offer of getting up to 'K' additional candies for free.
Calculate the minimum cost by selecting the cheapest candies and taking free ones.
Calculate the maximum cost by selecting the most expensive candies and taking free ones.
Q2. Word Break Problem Statement
You are provided with a continuous non-empty string (referred to as 'sentence') which contains no spaces and a dictionary comprising a list of non-empty strings (known as 'words'). ...read more
Given a dictionary of words and a continuous string, generate all possible sentences by inserting spaces.
Use recursion to generate all possible combinations of words from the dictionary to form sentences.
Check if a substring of the sentence matches any word in the dictionary, if so, recursively call the function with the remaining substring.
Keep track of the current sentence being formed and add it to the result when the entire sentence is processed.
Handle edge cases like emp...read more
Q3. Best Time To Buy and Sell Stock Problem Statement
You are given an array 'PRICES' of 'N' integers, where 'PRICES[i]' represents the price of a certain stock on the i-th day. An integer 'K' is also provided, ind...read more
Determine the maximum profit achievable with at most K transactions by buying and selling stocks.
Iterate through the array and keep track of the minimum price to buy and maximum profit for each transaction.
Use dynamic programming to store the maximum profit at each day with each possible number of transactions.
Consider edge cases such as when K is 0 or when the array is empty.
Example: For input N = 6, PRICES = [3, 2, 6, 5, 0, 3], K = 2, the output should be 7.
Q4. Minimum Steps for a Knight to Reach Target
Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.
Expl...read more
Calculate minimum steps for a Knight to reach target position on a chessboard.
Use BFS algorithm to find the shortest path from Knight's starting position to target position.
Consider all possible moves of the Knight on the chessboard.
Keep track of visited positions to avoid revisiting them.
Return the minimum number of moves required to reach the target position.
Q5. Problem Statement
Given an integer array ARR
of size N
, replace each element of this array with its corresponding rank.
Explanation
The rank of an element is an integer between 1 and N
(inclusive) that represen...read more
Replace elements in an array with their corresponding ranks based on given rules.
Iterate through the array and assign ranks based on the rules provided.
Handle equal elements by assigning them the same rank.
Return the modified array with elements replaced by their ranks.
Q6. Delete the Middle Node from a Singly Linked List
Given a singly linked list of integers, the task is to remove the middle node from this list.
Input:
The first line of input includes an integer 'T' which denote...read more
Remove the middle node from a singly linked list of integers.
Identify the middle node using slow and fast pointers technique.
Update the pointers to remove the middle node.
Handle cases where there are two middle nodes by removing the first one.
Return NULL if no middle node exists.
Achieve O(N) time and O(1) space complexity with a single traversal.
Q7. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
Detect if a singly linked list forms a cycle by checking if a node's next points back to a previous node.
Use Floyd's Tortoise and Hare algorithm to detect a cycle in the linked list.
Initialize two pointers, slow and fast, and move them at different speeds through the list.
If there is a cycle, the two pointers will eventually meet at some node.
If one of the pointers reaches the end of the list (null), there is no cycle.
Q8. Stack with getMin Operation
Create a stack data structure that supports not only the usual push and pop operations but also getMin(), which retrieves the minimum element, all in O(1) time complexity without usi...read more
Implement a stack with getMin operation in O(1) time complexity without using extra space.
Use two stacks - one to store the actual elements and another to store the minimum values encountered so far.
When pushing an element, check if it is smaller than the current minimum and if so, push it onto the minimum stack.
When popping an element, check if it is the current minimum and if so, pop from the minimum stack as well.
For getMin operation, simply return the top element of the m...read more
Q9. Right View of Binary Tree
Given a binary tree of integers, your task is to output the right view of the tree.
The right view of a binary tree includes the nodes that are visible when the tree is observed from t...read more
The task is to output the right view of a binary tree, which includes the nodes visible when observed from the right.
Perform a level order traversal of the binary tree.
For each level, add the rightmost node to the result list.
Print the result list as the right view of the binary tree.
Handle null nodes by skipping them during traversal.
Q10. Left View of a Binary Tree Problem Statement
Given a binary tree, your task is to print the left view of the tree.
Example:
Input:
The input will be in level order form, with node values separated by a space. U...read more
Print the left view of a binary tree given in level order form.
Traverse the tree level by level and print the first node of each level
Use a queue to keep track of nodes at each level
Consider null nodes as well while traversing the tree
Interview Process at Vega Conveyors & Automation
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month