Data Analytics
Data Analytics Interview Questions and Answers for Freshers
Q1. Lexicographically Smallest Array Problem Statement
You are given an array ARR
of 'N' integers and a positive integer 'K'.
Your task is to determine the lexicographically smallest array that can be obtained by p...read more
The task is to determine the lexicographically smallest array that can be obtained by performing at most 'K' swaps of consecutive elements.
Iterate through the array and swap elements to make the array lexicographically smallest.
Keep track of the number of swaps made and stop when the limit 'K' is reached.
Use a sorting algorithm to find the lexicographically smallest array after at most 'K' swaps.
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.
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 denominations that can make the change.
Q3. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Given an array and a target sum, find pairs of elements that add up to the target sum.
Iterate through the array and for each element, check if the complement (target sum - current element) exists in a hash set.
If the complement exists, add the pair to the result list.
Sort the result list based on the first element of each pair, and then the second element if the first elements are equal.
Q4. Rotting Oranges Problem Statement
You are given a grid containing oranges where each cell of the grid can contain one of the three integer values:
- 0 - representing an empty cell
- 1 - representing a fresh orange...read more
Find the minimum time required to rot all fresh oranges in a grid.
Iterate through the grid to find rotten oranges and their adjacent fresh oranges.
Use BFS or DFS to simulate the rotting process and track the time taken.
Return the minimum time taken to rot all fresh oranges or -1 if not possible.
Q5. K-th Largest Number in a BST
Given a binary search tree (BST) consisting of integers and containing 'N' nodes, your task is to find and return the K-th largest element in this BST.
If there is no K-th largest e...read more
Find the K-th largest element in a binary search tree.
Perform an in-order traversal of the BST to get elements in ascending order
Return the (N-K)th element from the end of the in-order traversal
Handle cases where K is out of bounds or no K-th largest element exists
Q6. Longest Common Prefix Problem Statement
You are given an array ‘ARR’ consisting of ‘N’ strings. Your task is to find the longest common prefix among all these strings. If there is no common prefix, you have to ...read more
Find the longest common prefix among an array of strings.
Iterate through the characters of the first string and compare with corresponding characters of other strings.
Stop when a mismatch is found or when reaching the end of the shortest string.
Return the prefix found so far as the longest common prefix.
Share interview questions and help millions of jobseekers 🌟
Q7. Peak Element Finder
For a given array of integers arr
, identify the peak element. A peak element is an element that is greater than its neighboring elements. Specifically, if arr[i]
is the peak, then both arr[i...read more
Find the peak element in an array of integers.
Iterate through the array and check if the current element is greater than its neighbors.
Handle edge cases where the first or last element can be a peak.
Return the peak element found.
Q8. Evaluate Division Problem Statement
Given an array of pairs of strings equations
representing a fraction and an array of real numbers values
. Each element in equations
denotes a fraction with the first string a...read more
Evaluate division problem statement with given fractions and values to calculate the value of a given fraction.
Use a graph data structure to represent the fractions and values.
Perform depth-first search (DFS) to find the value of the given fraction.
Multiply the values of the fractions along the path from numerator to denominator to get the final result.
Data Analytics Jobs
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month