Dunzo
10+ Hyundai Corporation Interview Questions and Answers
Q1. 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.
Q2. 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
Q3. 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
Q4. 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
Q5. 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.
Q6. 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.
Q7. 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.
Q8. 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
Q9. 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.
Q10. 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
Q11. 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
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month