Dunzo
30+ Carbynetech Interview Questions and Answers
Q1. Maximum Coins Collection Problem
Imagine a two-dimensional grid with 'N' rows and 'M' columns, where each cell contains a certain number of coins. Alice and Bob want to maximize the total number of coins they c...read more
Given a matrix of coins, Alice and Bob have to collect maximum coins with certain conditions.
Alice starts from top left corner and Bob starts from top right corner
They can move to (i+1, j+1) or (i+1, j-1) or (i+1, j)
They have to collect all the coins that are present at a cell
If Alice has already collected coins of a cell, then Bob gets no coins if goes through that cell again
Q2. Arithmetic Subarrays Problem Statement
You are provided with an array A
of length N
. Your task is to determine the number of arithmetic subarrays present within the array A
.
Explanation:
An arithmetic subarray ...read more
Count the number of arithmetic subarrays in an array.
An arithmetic subarray has 3 or more elements with the same difference between consecutive elements.
Loop through the array and check for all possible subarrays with 3 or more elements.
If the difference between consecutive elements is the same, increment the count.
Return the count for each test case.
Q3. Distance To Nearest 1 in a Binary Matrix Problem
Given a binary matrix MAT
containing only 0s and 1s of size N x M, find the distance of the nearest cell containing 1 for each cell in the matrix.
The distance i...read more
Given a binary matrix, find the distance of the nearest cell having 1 in the matrix for each cell.
Use BFS to traverse the matrix and find the nearest cell having 1 for each cell.
Initialize the output matrix with maximum possible distance.
If the current cell has 1, distance is 0, else update distance based on the nearest cell having 1.
Q4. Asteroid Collision Problem Description
Given an array/list ASTEROIDS
representing asteroids aligned in a row, each element's absolute value identifies the asteroid's size, while its sign indicates the direction...read more
Determine the state of asteroids after collisions occur.
Iterate through the array of asteroids and simulate collisions between adjacent asteroids.
Use a stack to keep track of remaining asteroids after collisions.
Handle cases where asteroids moving in opposite directions collide and destroy each other.
Handle cases where asteroids moving in the same direction do not collide.
Q5. Container with Most Water Problem Statement
Given a sequence of 'N' space-separated non-negative integers A[1], A[2], ..., A[i], ..., A[n], where each number in the sequence represents the height of a line draw...read more
Find two lines to form a container with maximum water area on a Cartesian plane.
Iterate through the array from both ends to find the maximum area.
Calculate the area using the formula: (min(height[left], height[right]) * (right - left)).
Update the pointers based on the height of the lines to maximize the area.
Q6. Number of Subsequences with Even and Odd Sum
Your task is to determine the number of subsequences with odd sums and the number of subsequences with even sums from a given array of positive integers. As resultin...read more
Count the number of subsequences with odd and even sums in a given array of positive integers modulo 10^9 + 7.
Use dynamic programming to keep track of the count of subsequences with odd and even sums.
Consider the parity of each element in the array to determine the count of subsequences with odd and even sums.
Apply modulo 10^9 + 7 to handle large resulting numbers.
Example: For input [1, 2, 3], there are 3 subsequences with odd sums and 4 subsequences with even sums.
Q7. Minimum Cost to Reduce Array Problem Statement
You are given an array ARR
containing N
positive integers. Your task is to reduce the size of this array to 1 by repetitively merging adjacent elements. Each time ...read more
Find the minimum cost to reduce an array to a single element by merging adjacent elements with their sum.
Iteratively merge adjacent elements to minimize total cost
Choose pairs to merge strategically to reduce cost
Calculate sum of adjacent elements and update array size
Q8. Word Break II Problem Statement
Given a non-empty string 'S' containing no spaces and a dictionary of non-empty strings, generate and return all possible sentences by adding spaces in the string 'S', such that ...read more
Given a string and a dictionary, generate all possible sentences by adding spaces between words from the dictionary.
Use backtracking to generate all possible sentences by recursively adding words from the dictionary to the current sentence.
Check if the current substring of the input string exists in the dictionary, if so, add it to the current sentence and continue recursively.
When the entire input string is processed, add the current sentence to the result list.
Repeat the pr...read more
Q9. Maximum Size Rectangle Binary Sub-Matrix with All 1s
Given a binary-valued matrix of size N x M
, your task is to determine the largest area of a submatrix that contains only 1's.
Input:
The first line contains ...read more
Find the largest area of a submatrix containing only 1's in a binary matrix.
Iterate over each cell in the matrix and calculate the maximum area of submatrix with all 1's ending at that cell.
Use dynamic programming to keep track of the maximum area ending at each cell.
Update the maximum area as you iterate through the matrix.
Return the overall maximum area found in the matrix.
Q10. Wildcard Pattern Matching Problem Statement
Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.
The wildcard pattern may include the charac...read more
Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.
Create a dynamic programming matrix to store intermediate results
Handle cases for '?' and '*' characters separately
Check if the characters match or '*' can be used to match any sequence of characters
Q11. Anagram Substring Search
Given two strings 'STR' and 'PTR', identify all starting indices of 'PTR' anagram substrings in 'STR'. Two strings are anagrams if one can be rearranged to form the other.
Input:
First ...read more
Identify starting indices of anagram substrings of 'PTR' in 'STR'.
Use a sliding window approach to check for anagrams of 'PTR' in 'STR'.
Create a frequency map of characters in 'PTR' and 'STR' to compare.
Slide the window along 'STR' and check if the frequency maps match.
Return the starting indices where anagrams are found.
Q12. Bipartite Graph Problem Statement
Given an undirected graph of 'V' vertices (labeled 0, 1, ..., V-1) and 'E' edges, the task is to determine whether the graph is bipartite.
Explanation:
A bipartite graph is one...read more
The task is to determine whether a given undirected graph is bipartite or not.
Create a function to check if the graph can be colored using two colors without any adjacent vertices sharing the same color.
Use graph coloring algorithms like BFS or DFS to determine if the graph is bipartite.
Check for odd-length cycles in the graph, as a bipartite graph cannot have odd-length cycles.
Consider using a boolean array to keep track of visited vertices and their colors while traversing ...read more
Q13. Convert Binary Tree to Mirror Tree Problem Statement
Given a binary tree, convert this binary tree into its mirror tree. A binary tree is a tree in which each parent node has at most two children. The mirror of...read more
Convert a binary tree into its mirror tree by interchanging left and right children of non-leaf nodes.
Traverse the binary tree in a recursive manner and swap the left and right children of each non-leaf node.
Use a temporary variable to swap the children of each node.
Ensure to handle cases where a node may have only one child or no children.
Implement the function to convert the given binary tree to its mirror tree in place.
Q14. Next Greater Element Problem Statement
You are given an array arr
of length N
. For each element in the array, find the next greater element (NGE) that appears to the right. If there is no such greater element, ...read more
The task is to find the next greater element for each element in an array to its right, if no greater element exists return -1.
Use a stack to keep track of elements for which the next greater element is not found yet.
Iterate through the array from right to left, popping elements from the stack until a greater element is found.
Store the next greater element for each element in a separate array.
Q15. Longest Common Subsequence Problem Statement
Given two strings STR1
and STR2
, determine the length of their longest common subsequence.
A subsequence is a sequence that can be derived from another sequence by d...read more
The problem involves finding the length of the longest common subsequence between two given strings.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the lengths of common subsequences of substrings.
Iterate through the strings to fill the array and find the length of the longest common subsequence.
Return the length of the longest common subsequence for each test case.
Q16. Convert Array to Min Heap Task
Given an array 'ARR' of integers with 'N' elements, you need to convert it into a min-binary heap.
A min-binary heap is a complete binary tree where each internal node's value is ...read more
Convert the given array into a min-binary heap by following min-heap properties.
Iterate through the array and heapify each node starting from the last non-leaf node to the root.
For each node, compare it with its children and swap if necessary to maintain min-heap property.
Continue this process until the entire array satisfies the min-heap property.
Q17. Valid Parentheses Problem Statement
Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.
Input:
The first line contains an integer...read more
The task is to determine if a given string consisting of parentheses is balanced or not.
Use a stack data structure to keep track of opening parentheses
Iterate through the string and push opening parentheses onto the stack and pop when encountering a closing parenthesis
If at the end the stack is empty, the string is balanced, otherwise it is not
Q18. Left View of a Binary Tree
Given a binary tree, your task is to print the left view of the tree. The left view of a binary tree contains the nodes visible when the tree is viewed from the left side.
Input:
The ...read more
Print the left view of a binary tree, containing nodes visible from the left side.
Traverse the tree level by level, keeping track of the leftmost node at each level
Use a queue for level order traversal and a map to store the leftmost nodes
Print the values of leftmost nodes stored in the map as the left view of the tree
Q19. Trie Data Structure Implementation
Design and implement a Trie (Prefix Tree) which should support the following two operations:
1. Insert a word into the Trie. The operation is marked as 'insert(word)'.
2. Searc...read more
Implement a Trie data structure supporting insert and search operations efficiently.
Implement a Trie class with insert and search methods.
Use a nested class Node to represent each node in the Trie.
For insert operation, iterate through each character in the word and create nodes as needed.
For search operation, traverse the Trie based on the characters in the word to check for existence.
Return 'TRUE' if the word is found in the Trie, 'FALSE' otherwise.
Q20. 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 (leftmost node)
Use a queue to keep track of nodes at each level
Time complexity should be O(n) where n is the number of nodes in the tree
Implementing undo and redo operations for MS Word
Maintain a stack for undo operations and another stack for redo operations
Whenever a change is made, push the previous state onto the undo stack
When undo is triggered, pop the state from undo stack and push it onto redo stack
When redo is triggered, pop the state from redo stack and push it onto undo stack
Ensure to update the document state accordingly after each undo or redo operation
Q22. How challenging is handling blue coloured employees
It is not appropriate to refer to employees by their skin color. All employees should be treated equally and with respect.
It is important to avoid using language that could be perceived as discriminatory or offensive
Focus on individual performance and behavior rather than skin color
Provide equal opportunities for all employees to succeed
Create a culture of inclusivity and diversity
Train managers and employees on diversity and inclusion best practices
Q23. What would be the ideal EPH for any city.
Ideal EPH for a city depends on various factors such as population, geography, climate, and infrastructure.
EPH stands for 'Events Per Hour', which refers to the number of emergency incidents that occur in a city per hour.
The ideal EPH for a city can vary depending on the size of the population, the geography of the area, the climate, and the infrastructure available to respond to emergencies.
For example, a city with a high population density and limited emergency services may...read more
Q24. What tools are required to run a smooth operation
Tools required for a smooth operation include inventory management software, communication tools, and employee scheduling software.
Inventory management software to track stock levels and ensure timely restocking
Communication tools such as email, phone, and messaging apps to keep in touch with employees and customers
Employee scheduling software to manage shifts and ensure adequate staffing levels
Point of sale (POS) system to process transactions and track sales data
Security sy...read more
Q25. Overall supply needed for N number of tasks
The overall supply needed for N number of tasks depends on the specific requirements of each task.
The supply needed for each task should be assessed individually
Factors such as task duration, complexity, and required resources should be considered
The total supply needed can be calculated by adding up the supply requirements for each task
Regular monitoring and adjustment of supply levels may be necessary
Q26. Last ctc and expecting in current organisation
I am currently earning INR 8 lakhs per annum and expecting a hike of 10% in my current organization.
My last CTC was INR 8 lakhs per annum.
I am expecting a hike of 10% in my current organization.
I am open to negotiation based on the job responsibilities and market standards.
Q27. Privious company details work responsibility
Q28. What you know abou sales
Sales involves identifying customer needs, presenting products or services, and closing deals to generate revenue.
Understanding customer needs and preferences
Effective communication and persuasion skills
Product knowledge and ability to highlight benefits
Negotiation and closing techniques
Building and maintaining customer relationships
Meeting sales targets and goals
Q29. SQL joins difference
SQL joins are used to combine rows from two or more tables based on a related column between them.
Types of SQL joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
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 JOIN returns rows when there is a match in one of ...read more
Q30. What is your expected CTC
My expected CTC is in line with industry standards and commensurate with my experience and skills.
I have researched the market and have a good understanding of the salary range for this position
I am open to negotiation based on the overall compensation package
I am looking for a fair and competitive salary that reflects my qualifications and contributions to the company
Q31. What abou your study
I have a Bachelor's degree in Business Administration with a focus on sales and marketing.
Bachelor's degree in Business Administration
Focus on sales and marketing
Top HR Questions asked in Carbynetech
Interview Process at Carbynetech
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month