Walmart
300+ Interview Questions and Answers
Ninja is given an array of integers that contain numbers in random order. He needs to write a program to find and return the number which occurs the maximum times in the given input. He ...read more
You are given an integer ‘N’, your task is to find and return the N’th Fibonacci number using matrix exponentiation.
Since the answer can be very large, return the answer modulo 10^9 +7.
Fib...read more
Ninja is given an integer ‘N’. One day Ninja decides to do the sum of all digits and replace the ‘N’ with the sum of digits until it becomes less than 10. Ninja wants to find what will be the value...read more
You have been given a string STR and a non-empty string PTR. Your task is to find all the starting indices of PTR’s anagram in STR.
An anagram of a string is another string which contains the s...read more
You have been given a text message. You have to return the Run-length Encoding of the given message.
Run-length encoding is a fast and simple method of encoding strings. The basic idea is to r...read more
You are given a bag of size 'W' kg and provided with the costs of packets with different weights of oranges as a list/array with the name 'cost'. Every i-th position in the cost denot...read more
Q7. What would be the ideal data structure to represent people and friend relations in facebook
Graph
Use a graph data structure to represent people as nodes and friend relations as edges
Each person can be represented as a node with their unique identifier
Friend relations can be represented as directed edges between nodes
This allows for efficient traversal and retrieval of friend connections
You have been given an array/list ‘ARR’ of integers consisting of ‘N’ integers. In one operation you can increase an element by 1. Your task is to return the minimum numb...read more
You are given an array arr of N non-negative integers, you need to return true if the array elements consist of consecutive numbers otherwise return false.
For Example: If the given array is...read more
You are given an infinite supply of coins of each of denominations D = {D0, D1, D2, D3, ...... Dn-1}. You need to figure out the total number of ways W, in which you can make a change fo...read more
One day Ninja goes to play some intellectual games. There was a game where Ninja is given a string of balanced parentheses 'STR' and he has to calculate the score of that using the given rule...read more
Given a string “STR”, you need to return all the possible non-empty subsequences with distinct characters. You can return the strings in any order.
Note:
If the same string can be generated m...read more
You are trying to cook an egg for exactly fifteen minutes, but instead of a timer, you are given two ropes which burn for exactly 1 hour each. The ropes, however, are of uneven densities – i e , half the ...read more
You have been given a binary tree of integers. Your task is to calculate the sum of all the leaf nodes which are present at the deepest level of this binary tree. If there are no such nodes, p...read more
You are given the ‘POSTORDER’ and ‘PREORDER’ traversals of a binary tree. The binary tree consists of ‘N’ nodes where each node represents a distinct po...read more
You are given two strings, ‘A’ and ‘B’ each of length ‘N’. Your task is to print 1 if ‘A’ is similar to ‘B’.
Note :
String ‘A’ is said to be similar to string ‘B’ if and only if 1. ‘A’ is equal t...read more
Design and implement a data structure which supports the following operations:
insert(X): Inserts an element X in the data structure and returns true if the ...read more
You are given an array “NUMS” consisting of N integers and an integer, K. Your task is to determine the maximum sum of an increasing subsequence of length K.
Note:
1. The array may contai...read more
You are given a string 'S', check if there exists any permutation of the given string that is a palindrome.
Note :
1. A palindrome is a word or phrase that reads the same from forward and ...read more
Given an array/list of integers of length ‘N’, there is a sliding window of size ‘K’ which moves from the beginning of the array, to the very end. You can only see the ‘K’ nu...read more
You are given an array of N elements. This array represents the digits of a number. In an operation, you can swap the value at any two indices. Your task is to find the maximum number by using ope...read more
You are given a binary tree in which each node contains an integer value and a number ‘K’. Your task is to print every path of the binary tree with the sum of nodes in the path as ‘...read more
You have been given a sentence ‘S’ in the form of a string and a word ‘W’, you need to find whether the word is present in the given sentence or not. The word must...read more
Q24. Custom implementation of stack where there are two additional methods that return the min and max of the elements in the stack
Custom stack with methods to return min and max elements
Implement a stack using an array or linked list
Track the minimum and maximum elements using additional variables
Update the minimum and maximum variables during push and pop operations
Implement methods to return the minimum and maximum elements
Mr. X is a professional robber planning to rob houses along a street. Each house has a certain amount of money hidden. All houses along this street are arranged in a circle. That means the first hou...read more
Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:
1. get(key) - Return the value of the key if the key exists in the cache, o...read more
Nth term of Fibonacci series F(n), where F(n) is a function, is calculated using the following formula -
F(n) = F(n-1) + F(n-2), Where, F(1) = F(2) = 1
Provided N you have to find out the ...read more
You are given a binary tree. Your task is to check whether the given binary tree is a Complete Binary tree or not.
A Complete Binary tree is a binary tree whose every level,...read more
You are given the root node of a binary tree with N nodes, whose nodes have integer values. Your task is to find the maximum depth of the given Binary tree.
Depth of a binary tree...read more
You have been given a Binary Tree of integers. You are supposed to return the top view of the given binary tree.
Top view of the binary tree is the set of nodes which are visible when...read more
1. Draw a BST with randomly selected 12 values of your choice. Asked what’s the approach I am following while creating it. Write Code and Explain all the traversals for that particular tree. (i...read more
You are given an array ‘ARR’ of size ‘N’ containing each number between 1 and ‘N’ - 1 at least once. There is a single integer value that is present in the array twice. Your task is to find th...read more
Bob lives with his wife in a city named Berland. Bob is a good husband, so he goes out with his wife every Friday to ‘Arcade’ mall.
‘Arcade’ is a very famous mall in Berland. It has a very unique t...read more
You are given ‘N’ pairs of integers in which the first number is always smaller than the second number i.e in pair (a,b) -> a < b always. Now we define a pair chain as the continuous ar...read more
You are given two linked lists L1 and L2 which are sorted in ascending order. You have to make a linked list with the elements which are present in both the linked lists and are pres...read more
You are given an array, 'ARR', consisting of ‘N’ integers. You are also given two other integers, ‘SUM’ and ‘MAXVAL’. The elements of this array follow a special property that the absolu...read more
You are given an array Arr consisting of N integers. You need to find the equilibrium index of the array.
An index is considered as an equilibrium index if the sum of elements of the array to t...read more
You are given an array/list ‘ARR’ of ‘N’ positive integers where each element describes the length of the stick. You have to connect all sticks into one. At a time, you can join an...read more
Q39. Given a tree and a node, print all ancestors of Node
Given a tree and a node, print all ancestors of Node
Start from the given node and traverse up the tree
While traversing, keep track of the parent nodes
Print the parent nodes as you traverse up until reaching the root
You have been given a binary tree of integers with N number of nodes. Your task is to check if that input tree is a BST (Binary Search Tree) or not.
A binary search tree (BST) is a binary tree data ...read more
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to return the list of all pairs of elements such that each sum of elements of each pair equals 'S'.
Note:
Each pair shou...read more
Q42. Explain useState for managing state, useEffect for handling side effects, useMemo for performance optimization, and useCallback for memoizing functions. Understand how these hooks enhance functional components.
Explanation of useState, useEffect, useMemo, and useCallback hooks in React functional components.
useState is used to manage state in functional components
useEffect is used for handling side effects like data fetching, subscriptions, etc.
useMemo is used for performance optimization by memoizing expensive calculations
useCallback is used for memoizing functions to prevent unnecessary re-renders
These hooks enhance functional components by providing state management, side effect ...read more
You are given a string ‘str’ of size ‘N’. Your task is to remove consecutive duplicates from this string recursively.
For example:
If the input string is ‘str’ = ”aazbbby”, then you...read more
Given a string (STR) of length N, you have to create a new string by performing the following operation:
Take the smallest character from the first 'K' characters of STR, remove it from STR...read more
Q45. what will happen if I write without condition in for loop?
The for loop will run indefinitely without any condition to terminate it.
The loop will continue executing until it is manually interrupted or the program crashes.
This can lead to a program becoming unresponsive or consuming excessive resources.
It is important to always include a condition in a for loop to control its execution.
You have been given a sorted array of length ‘N’. You need to construct a balanced binary search tree from the array. If there can be more than one possible tree, then you can return ...read more
Given a graph, check whether the graph is bipartite or not. Your function should return true if the given graph's vertices can be divided into two independent sets, ‘U’ and ‘V’ such that every ed...read more
How can you tune the hyper parameters of XGboost algorithm?
Ninja loves playing with numbers. One day Alice gives him some numbers and asks him to find the Kth largest value among them.
Input Format:
The first line of input contains an integer ‘T,’ de...read more
1. To write a function that will swap two numbers (2 or 3 fixed), i.e. if I got 2, I need to return 3 and vice versa.
2. Write SQL query for a table given by him.
3. Two classes are there Base and Derived ...read more
You are given an array 'ARR' of integers of length N. Your task is to find the next smaller element for each of the array elements.
Next Smaller Element for an array element is the first ele...read more
Q52. How to add and manipulate elements in arrays using JavaScript (e.g., inserting "watermelon" in the middle)?
To add and manipulate elements in arrays using JavaScript, you can use array methods like splice() and slice().
Use the splice() method to insert elements into an array at a specific index. For example, arr.splice(index, 0, 'watermelon') will insert 'watermelon' at the specified index without removing any elements.
To manipulate elements in an array, you can use methods like splice() to remove elements or slice() to extract a portion of the array.
Remember that arrays in JavaScr...read more
Q53. 1. Design and code a scheduler for allocating meeting rooms for the given input of room counts and timestamps: Input : No of rooms : 2 Time and dutation: 12pm 30 min Output: yes. Everytime the code runs it shou...
read moreDesign and code a scheduler for allocating meeting rooms based on input of room counts and timestamps.
Create a table with columns for room number, start time, and end time
Use SQL queries to check for available slots and allocate rooms
Consider edge cases such as overlapping meetings and room availability
Use a loop to continuously check for available slots and allocate rooms
Implement error handling for invalid input
Q54. What are the different approach you use for data cleaning.
Different approaches for data cleaning include removing duplicates, handling missing values, correcting inconsistent data, and standardizing formats.
Remove duplicates
Handle missing values
Correct inconsistent data
Standardize formats
Use statistical methods to identify outliers
Check for data accuracy and completeness
Normalize data
Transform data types
Apply data validation rules
‘N’ people are standing in a circle numbered from ‘1’ to ‘N’ in clockwise order. First, the person numbered 1 will proceed in a clockwise direction and will skip K-1 persons including itself and will ki...read more
Q56. How can you tune the hyper parameters of XGboost,Random Forest,SVM algorithm?
Hyperparameters of XGBoost, Random Forest, and SVM can be tuned using techniques like grid search, random search, and Bayesian optimization.
For XGBoost, important hyperparameters to tune include learning rate, maximum depth, and number of estimators.
For Random Forest, important hyperparameters to tune include number of trees, maximum depth, and minimum samples split.
For SVM, important hyperparameters to tune include kernel type, regularization parameter, and gamma value.
Grid ...read more
Write a SQL query to print the highest salary of each department in a employee table that contains employee details - department to which employee belong, salary of employee.
1. Whats polymorphism - compile time and run time.
2. What are exceptions in Java - Since my primary language was C++, I explained exception in C++ only.
3. What are collections in Java- list, ...read more
How to fit a time series model? State all the steps you would follow.
Q60. Code to determine the median of datapoints present in two sorted arrays. Most efficient algo
Code to find median of datapoints in two sorted arrays
Use binary search to find the median index
Divide the arrays into two halves based on the median index
Compare the middle elements of the two halves to determine the median
Exception handling in C++ in detail.
What do mean by OOPS.
What is inheritance.
Create a database to store the information of employees and their salaries (just explain)
What are insertion, delet...read more
You are given a graph with 'N' vertices numbered from '1' to 'N' and 'M' edges. You have to colour this graph in two different colours, say blue and red such that no two vertices connected by an...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
Q63. Microservices and their communication patterns. How is it implemented in your project and why?
Microservices are implemented using RESTful APIs and message brokers for asynchronous communication.
RESTful APIs are used for synchronous communication between microservices.
Message brokers like Kafka or RabbitMQ are used for asynchronous communication.
Microservices communicate with each other using HTTP requests and responses.
Each microservice has its own database and communicates with other microservices through APIs.
Microservices are loosely coupled and can be developed an...read more
What is a basic form of GRANT statement?
Calculate the result of the following prefix expression: +,-,*,8,4,/,6,2,5
If a new node is added into a red-black tree, which statements are true ?
What...read more
Q65. What do these hyper parameters in the above mentioned algorithms actually mean?
Hyperparameters are settings that control the behavior of machine learning algorithms.
Hyperparameters are set before training the model.
They control the learning process and affect the model's performance.
Examples include learning rate, regularization strength, and number of hidden layers.
Optimizing hyperparameters is important for achieving better model accuracy.
What are outlier values and how do you treat them?
Q67. How to generate an unique id for a massive parallel system?
An unique id for a massive parallel system can be generated using a combination of timestamp, machine id and a random number.
Use a timestamp to ensure uniqueness
Include a machine id to avoid collisions in a distributed system
Add a random number to further increase uniqueness
Consider using a UUID (Universally Unique Identifier) for simplicity
Ensure the id generation algorithm is thread-safe
Q68. Understand setting up a Redux store, connecting components, and managing actions and reducers. Be familiar with middleware like Redux Thunk or Redux Saga for handling asynchronous actions.
Setting up Redux store, connecting components, managing actions and reducers, and using middleware like Redux Thunk or Redux Saga for handling asynchronous actions.
Setting up a Redux store involves creating a store with createStore() function from Redux, combining reducers with combineReducers(), and applying middleware like Redux Thunk or Redux Saga.
Connecting components to the Redux store can be done using the connect() function from react-redux library, which allows compon...read more
Q69. How you get your data in your organization
Data is collected from various sources including databases, APIs, and user input.
We have access to multiple databases where we can extract relevant data
We use APIs to gather data from external sources such as social media platforms
Users can input data through forms or surveys
We also collect data through web scraping techniques
Q70. Sequence of Execution of SQL codes. Select - Where-from-Having- order by etc
The sequence of execution of SQL codes is Select-From-Where-Group By-Having-Order By.
Select: choose the columns to display
From: specify the table(s) to retrieve data from
Where: filter the data based on conditions
Group By: group the data based on a column
Having: filter the grouped data based on conditions
Order By: sort the data based on a column
Q71. Write code to describe database and Columns from a particular table
Code to describe database and columns from a table
Use SQL SELECT statement to retrieve column names and data types
Use DESC command to get table structure
Use INFORMATION_SCHEMA.COLUMNS to get detailed information about columns
Use SHOW CREATE TABLE to get table creation statement
Q72. 1. Create a program for a Race, where 5 people will start the race at the same time and return who finishes first. using multithreading.
A program to simulate a race with 5 people using multithreading and determine the winner.
Create a class for the race participants
Implement the Runnable interface for each participant
Use a thread pool to manage the threads
Start all threads simultaneously
Wait for all threads to finish
Determine the winner based on the finishing time
Q73. Define Excel Functions Sum , Sum if , Count , CountA , Count Blanks
Excel functions are pre-built formulas that perform calculations or manipulate data in a spreadsheet.
Sum: adds up a range of numbers
Sum if: adds up a range of numbers based on a specified condition
Count: counts the number of cells in a range that contain numbers
CountA: counts the number of cells in a range that are not empty
Count Blanks: counts the number of empty cells in a range
Q74. Which design pattern you follow and why? Show some example.
I follow the MVC design pattern as it separates concerns and promotes code reusability.
MVC separates the application into Model, View, and Controller components.
Model represents the data and business logic.
View represents the user interface.
Controller handles user input and updates the model and view accordingly.
MVC promotes code reusability and maintainability.
Example: Ruby on Rails framework follows MVC pattern.
Q75. How to fit a time series model? State all the steps you would follow.
Steps to fit a time series model
Identify the time series pattern
Choose a suitable model
Split data into training and testing sets
Fit the model to the training data
Evaluate model performance on testing data
Refine the model if necessary
Forecast future values using the model
Why Java is platform independent and JVM platform dependent?
Q77. Difference between CSV file and Excel file
CSV files are plain text files that store tabular data, while Excel files are binary files that can contain multiple sheets and complex formatting.
CSV files are simpler and more lightweight compared to Excel files.
CSV files can be easily opened and edited using a text editor, while Excel files require specific software like Microsoft Excel.
CSV files do not support formulas, macros, or formatting options like colors and fonts, while Excel files do.
CSV files have a smaller file...read more
Q78. How much amount of data you Handel till now.
I have handled large amounts of data in my previous roles.
I have experience handling terabytes of data in my previous role as a data analyst at XYZ company.
I have worked with data from various sources such as databases, spreadsheets, and APIs.
I have also used tools like SQL, Python, and Excel to manipulate and analyze data.
I am comfortable working with both structured and unstructured data.
I have experience cleaning and transforming data to make it usable for analysis.
Q79. How do you ensure a payment does get credited to wrong employee account?
We implement multiple checks and balances to ensure payments are credited to the correct employee account.
We verify the employee's account number and name before processing any payment.
We implement a two-step verification process to ensure accuracy.
We conduct regular audits to ensure all payments are correctly credited.
We have a dedicated team to handle any payment discrepancies or errors.
We provide training to employees on how to verify and confirm payment details.
We use adv...read more
Q80. You have 3 friends. The probability of each telling truth is 2/3. All saying it's raining. What's the probability that it's actually raining
Probability of raining given 3 friends with 2/3 truth probability saying it's raining.
Use Bayes' theorem to calculate the probability
P(Raining | All Friends Saying It's Raining) = P(All Friends Saying It's Raining | Raining) * P(Raining) / P(All Friends Saying It's Raining)
P(All Friends Saying It's Raining | Raining) = 1
P(Raining) = Prior probability of raining
P(All Friends Saying It's Raining) = Probability of all friends saying it's raining
Q81. Difference between having and where clause
HAVING is used with GROUP BY to filter the results after grouping. WHERE is used to filter the results before grouping.
HAVING is used with GROUP BY clause while WHERE is used with SELECT clause.
HAVING is used to filter the results of aggregate functions while WHERE is used to filter individual rows.
HAVING is used to filter the results after grouping while WHERE is used to filter the results before grouping.
HAVING can only be used with aggregate functions while WHERE can be us...read more
Q82. Write query to find the top five employee salary?
Query to find the top five employee salaries
Use the SELECT statement to retrieve the employee salaries
Order the results in descending order using the ORDER BY clause
Limit the results to the top five using the LIMIT clause
Q83. What is the use if store procedure ?
Stored procedures are precompiled SQL statements that can be reused and executed multiple times.
Stored procedures improve performance by reducing network traffic and improving security.
They can be used to encapsulate business logic and provide a consistent interface to the database.
Stored procedures can also be used to simplify complex queries and transactions.
Examples include procedures for inserting, updating, and deleting data, as well as generating reports and performing ...read more
Q84. Mocking components in Jest, including handling props and named exports
Mocking components in Jest for testing with props and named exports
Use jest.mock() to mock components and their exports
For handling props, use jest.fn() to create mock functions and pass them as props to the component being tested
For named exports, use jest.mock() with a second argument to specify the module's exports
Q85. Design a Garbage collector similar to Java Garbage Collector with minimum configurations.
Design a Java-like Garbage Collector with minimal configurations.
Choose a garbage collection algorithm (e.g. mark-and-sweep, copying, generational)
Determine the heap size and divide it into regions (e.g. young, old, permanent)
Implement a root set to keep track of live objects
Set thresholds for garbage collection (e.g. occupancy, time)
Implement the garbage collection algorithm and test for memory leaks
Q86. 7. Which data structure you will use to search a lot of data.
I would use a hash table for efficient searching of a lot of data.
Hash tables provide constant time complexity for search operations.
They use a hash function to map keys to array indices, allowing for quick retrieval of data.
Examples of hash table implementations include dictionaries in Python and HashMaps in Java.
Q87. How instagram application works. If someone tagged you how you will get notification and how those reels are showing in your profile page...etc.
Instagram uses a notification system to alert users when they are tagged and displays reels on the profile page based on user preferences and algorithms.
Instagram uses a push notification system to alert users when they are tagged in a post or story.
Reels are displayed on the profile page based on user engagement, preferences, and algorithms.
The Explore page also suggests reels to users based on their interests and interactions on the platform.
Q88. what is memoization, also write polyfill of memoize
Memoization is a technique used in programming to store the results of expensive function calls and return the cached result when the same inputs occur again.
Memoization helps improve the performance of a function by caching its results.
It is commonly used in dynamic programming to optimize recursive algorithms.
Example: Memoizing a Fibonacci function to avoid redundant calculations.
Explain the hyper parameters in XGboost Algorithm .
Explain deadlock and its conditions.
What is synchronization?
What is paging?
Semaphore vs Mutex
Deadlock is a situation where two or more processes are unable to proceed because each is waiting for the other to release a resource.
Deadlock occurs when two or more processes are stuck in a circular wait, where each process is waiting for a resource held by another process.
The four necessary conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
Synchronization refers to the coordination of multiple processes or threads to ensure their...read more
Difference between Ridge and LASSO .
Q92. 3. How request flows in Spring boot MVC. 4. how many ways to instantiate a bean? 5. what will you do in case of a Java out-of-memory exception?
Request flows in Spring Boot MVC, ways to instantiate a bean, and handling Java out-of-memory exception.
Request flows in Spring Boot MVC: DispatcherServlet receives HTTP request, HandlerMapping maps request to appropriate controller, Controller processes request and returns response.
Ways to instantiate a bean: Constructor injection, setter injection, and using the @Bean annotation.
Handling Java out-of-memory exception: Analyze memory usage, increase heap size, optimize code, ...read more
What is Data Abstraction and how to achive it ?
Q94. A wooden cube of 5 cm each side. Painted. Now cut to smaller cube of 1cm side each. How many smaller cubes have all sides paintee, 4 sides paintee, 3 sides painted etc.
A 5cm wooden cube is cut into smaller 1cm cubes. Determine the number of cubes with different numbers of painted sides.
The original cube has 125 smaller cubes (5x5x5)
Each smaller cube has 6 faces, so there are 750 faces in total
The cubes on the edges have 3 painted sides, the ones on the corners have 3 painted sides, and the rest have 2 painted sides
There are 8 cubes on the corners, 12 on the edges, and 105 in the middle
There are 8 cubes with 3 painted sides, 36 with 2 painte...read more
RNN,CNN and difference between these two.
Q96. Use and purpose of Math.floor() in JavaScript.
Math.floor() is a method in JavaScript that rounds a number down to the nearest integer.
Math.floor() returns the largest integer less than or equal to a given number.
It is commonly used to convert a floating-point number to an integer.
Example: Math.floor(3.9) returns 3.
Static and Dynamic Polymorphism
Q98. what is Promise also write polyfill for Promise
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
A Promise is used to handle asynchronous operations in JavaScript.
It represents a value that may be available now, or in the future.
A polyfill for Promise can be implemented using the setTimeout function to simulate asynchronous behavior.
Q99. Word break String to Integer System design e commerce app
The interviewee was asked about word break, string to integer, and system design for an e-commerce app.
Word break: Given a string and a dictionary of words, determine if the string can be segmented into a space-separated sequence of dictionary words.
String to integer: Convert a string to an integer. Handle negative numbers and invalid inputs.
System design e-commerce app: Design an e-commerce app with features like product listing, search, cart, checkout, payment, and order tr...read more
Q100. Difference between Ridge and LASSO and their geometric interpretation.
Ridge and LASSO are regularization techniques used in linear regression to prevent overfitting.
Ridge adds a penalty term to the sum of squared errors, which shrinks the coefficients towards zero but doesn't set them exactly to zero.
LASSO adds a penalty term to the absolute value of the coefficients, which can set some of them exactly to zero.
The geometric interpretation of Ridge is that it adds a constraint to the size of the coefficients, which shrinks them towards the origi...read more
Top HR Questions asked in null
Interview Process at null
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month