Walmart
Dabur Interview Questions and Answers
Q1. 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.
Use dynamic programming to solve this problem efficiently.
Create a 2D array to store the number of ways to make change for each value using different denominations.
Initialize the base cases and then iterate through the denominations to fill up the array.
The final answer will be in the last cell of the array corresponding to the specified value.
Q2. Validate Binary Search Tree (BST)
You are given a binary tree with 'N' integer nodes. Your task is to determine whether this binary tree is a Binary Search Tree (BST).
BST Definition:
A Binary Search Tree (BST)...read more
Validate if a given binary tree is a Binary Search Tree (BST) or not.
Check if the left subtree of a node contains only nodes with data less than the node's data.
Check if the right subtree of a node contains only nodes with data greater than the node's data.
Recursively check if both the left and right subtrees are also binary search trees.
Example: For each node, ensure all nodes in its left subtree are less and all nodes in its right subtree are greater.
Q3. Duplicate Integer in Array
Given an array ARR
of size N
, containing each number between 1 and N-1
at least once, identify the single integer that appears twice.
Input:
The first line contains an integer, 'T', r...read more
Identify the duplicate integer in an array of size N containing numbers between 1 and N-1.
Iterate through the array and keep track of the frequency of each element using a hashmap.
Return the element with a frequency greater than 1 as the duplicate integer.
Ensure the constraints are met and a duplicate number is guaranteed to be present in the array.
Q4. Maximum Frequency Number Problem Statement
Given an array of integers with numbers in random order, write a program to find and return the number which appears the most frequently in the array.
If multiple elem...read more
The program finds the number that occurs the maximum times in an array of integers.
Iterate through the array and count the frequency of each number using a dictionary.
Keep track of the number with the maximum frequency and its index.
Return the number with the maximum frequency and the lowest index.
Q5. Next Smaller Element Problem Statement
You are provided with an array of integers ARR
of length N
. Your task is to determine the next smaller element for each array element.
Explanation:
The Next Smaller Elemen...read more
Find the next smaller element for each element in an array.
Iterate through the array from right to left and use a stack to keep track of elements.
Pop elements from the stack until a smaller element is found or the stack is empty.
If a smaller element is found, that is the next smaller element. If the stack is empty, there is no smaller element.
Q6. Graph Coloring Problem
You are given a graph with 'N' vertices numbered from '1' to 'N' and 'M' edges. Your task is to color this graph using two colors, such as blue and red, in a way that no two adjacent vert...read more
The problem is to color a graph with two colors such that no two connected vertices have the same color.
Use a graph coloring algorithm such as Depth First Search (DFS) or Breadth First Search (BFS).
Start with an arbitrary vertex and color it with one color (e.g., blue).
Color all its adjacent vertices with the other color (e.g., red).
Continue this process for all connected components of the graph.
If at any point, you encounter two adjacent vertices with the same color, it is n...read more
Q7. Josephus Problem Statement
Consider 'N' individuals standing in a circle, numbered consecutively from 1 to N, in a clockwise direction. Initially, the person at position 1 starts counting and will skip K-1 pers...read more
The Josephus Problem involves eliminating every Kth person in a circle of N individuals until only one person remains. Determine the position of the last person standing.
Use a circular linked list to simulate the elimination process efficiently
Implement a function to find the position of the last person standing based on the given N and K values
Consider edge cases such as when N=1 or K=1
Optimize the solution to handle large values of N and K efficiently
Interview Process at Dabur
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month