Josh Technology Group
NielsenIQ Interview Questions and Answers
Q1. Huffman Coding Challenge
Given an array ARR
of integers containing 'N' elements where each element denotes the frequency of a character in a message composed of 'N' alphabets of an alien language, your task is ...read more
Implement a function to generate Huffman codes for characters based on their frequencies in an alien language message.
Use a priority queue to build the Huffman tree efficiently.
Assign '0' and '1' to left and right branches of the tree respectively to generate unique binary codes.
Ensure that each code distinctly identifies its corresponding character and minimizes the total number of bits used for the message.
Q2. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to find the total number of ways to make change for a specified value using given denominations.
Create a dynamic programming table to store the number of ways to make change for each value up to the target value.
Iterate through each denomination and update the table accordingly based on the current denomination.
The final answer will be the value in the table at the target value.
Consider edge cases such as when the target value is 0 or when there are no denominatio...read more
Q3. Unique Element In Sorted Array
Nobita wants to impress Shizuka by correctly guessing her lucky number. Shizuka provides a sorted list where every number appears twice, except for her lucky number, which appears...read more
Find the unique element in a sorted array where all other elements appear twice.
Iterate through the array and XOR all elements to find the unique element.
Use a hash set to keep track of elements and find the unique one.
Sort the array and check adjacent elements to find the unique one.
Q4. Find Nodes at Distance K in a Binary Tree
Your task is to find all nodes that are exactly a distance K from a given node in an arbitrary binary tree. The distance is defined as the number of edges between nodes...read more
Find all nodes at distance K from a given node in a binary tree.
Perform a depth-first search starting from the target node to find nodes at distance K.
Use a recursive function to traverse the tree and keep track of the distance from the target node.
Maintain a set to store visited nodes and avoid revisiting them.
Return the list of nodes found at distance K from the target node.
Example: For the given input tree, target node 5, and K = 2, the output should be [7, 4, 0, 8].
Q5. Remove BST Keys Outside Given Range
Given a Binary Search Tree (BST) and a specified range [min, max], your task is to remove all keys from the BST that fall outside this range. The BST should remain valid afte...read more
Remove keys outside given range from a Binary Search Tree while keeping it valid.
Traverse the BST in inorder and remove nodes outside the specified range
Recursively check left and right subtrees for nodes to remove
Update pointers to maintain the validity of the BST
Return the inorder traversal of the adjusted BST
Q6. Inorder Successor in a Binary Tree
Given an arbitrary binary tree and a specific node within that tree, determine the inorder successor of this node.
Explanation:
The inorder successor of a node in a binary tre...read more
Given a binary tree and a specific node, find its inorder successor in the tree.
Perform an inorder traversal of the binary tree to find the successor node.
If the given node has a right child, the successor is the leftmost node in the right subtree.
If the given node does not have a right child, backtrack to find the ancestor whose left child is the given node.
Top Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month