Add office photos
Employer?
Claim Account for FREE

Walmart

3.8
based on 2.4k Reviews
Video summary
Filter interviews by

30+ ANSR Source Interview Questions and Answers

Updated 28 Feb 2025
Popular Designations

Q1. Working code with edge cases.

Ans.

Working code with edge cases is code that has been tested with extreme inputs to ensure it functions correctly.

  • Edge cases are inputs that are unlikely to occur but can cause unexpected behavior if not handled properly.

  • Examples of edge cases include empty inputs, null values, and inputs at the limits of the data type's range.

  • Working code with edge cases should be thoroughly tested to ensure it functions correctly in all scenarios.

Add your answer

Q2. Nth Fibonacci Number Problem Statement

Given an integer 'N', the task is to compute the N'th Fibonacci number using matrix exponentiation. Implement and return the Fibonacci value for the provided 'N'.

Note:

Si...read more

Ans.

Use matrix exponentiation to efficiently compute the Nth Fibonacci number modulo 10^9 + 7.

  • Implement matrix exponentiation to calculate Fibonacci numbers efficiently.

  • Use the formula F(n) = F(n-1) + F(n-2) with initial values F(1) = F(2) = 1.

  • Return the result modulo 10^9 + 7 to handle large Fibonacci numbers.

  • Optimize the solution to achieve better than O(N) time complexity.

Add your answer

Q3. Similar Strings Problem Statement

Determine whether two given strings, A and B, both of length N, are similar by returning a 1 if they are, otherwise return a 0.

Explanation:

String A is similar to string B if ...read more

Ans.

Determine if two strings are similar based on given conditions.

  • Check if the strings are equal first.

  • Then check if the strings can be divided into two halves with similar patterns.

  • Return 1 if the strings are similar, 0 otherwise.

Add your answer

Q4. Deepest Leaves Sum Problem Statement

Given a binary tree of integers, your task is to calculate the sum of all the leaf nodes present at the deepest level of this binary tree. If there are no such nodes, output...read more

Ans.

Calculate the sum of leaf nodes at the deepest level of a binary tree.

  • Traverse the binary tree to find the deepest level of leaf nodes.

  • Sum the leaf nodes at the deepest level.

  • Handle null nodes represented by -1.

  • Ensure the sum fits within a 32-bit integer.

Add your answer
Discover ANSR Source interview dos and don'ts from real experiences

Q5. Palindrome Permutation - Problem Statement

Determine if a permutation of a given string S can form a palindrome.

Example:

Input:
string S = "aab"
Output:
"True"
Explanation:

The permutation "aba" of the string ...read more

Ans.

Check if a permutation of a string can form a palindrome.

  • Create a frequency map of characters in the string.

  • Count the number of characters with odd frequencies.

  • If there is at most one character with odd frequency, return true.

  • Otherwise, return false.

Add your answer

Q6. Word Presence in Sentence

Determine if a given word 'W' is present in the sentence 'S' as a complete word. The word should not merely be a substring of another word.

Input:

The first line contains an integer 'T...read more
Ans.

Check if a given word is present in a sentence as a complete word.

  • Split the sentence into words using spaces as delimiter.

  • Check if the given word matches any of the words in the sentence.

  • Ensure that the word is not just a substring of another word in the sentence.

Add your answer
Are these interview questions helpful?

Q7. Remove Consecutive Duplicates Problem Statement

Given a string str of size N, your task is to recursively remove consecutive duplicates from this string.

Input:

T (number of test cases)
N (length of the string f...read more
Ans.

Recursively remove consecutive duplicates from a given string.

  • Use recursion to check for consecutive duplicates in the string.

  • If current character is same as next character, skip the next character.

  • Repeat the process until no consecutive duplicates are found.

Add your answer

Q8. Write a for loop in cpp to print n natural numbers without using semicolon (;)

Ans.

Use recursion to print n natural numbers in C++ without semicolon.

  • Define a function to print natural numbers recursively.

  • Call the function inside main function with n as argument.

  • Base case: if n is less than 1, return.

  • Print n and call the function with n-1 as argument.

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. 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

Ans.

Find the number with the maximum frequency in an array of integers.

  • Create a hashmap to store the frequency of each element in the array.

  • Iterate through the array to update the frequency count.

  • Find the element with the maximum frequency and return it.

  • If multiple elements have the same maximum frequency, return the one with the lowest index.

View 4 more answers

Q10. Take home project, with APIs fetch etc.

Ans.

Develop a take home project involving fetching data from APIs

  • Create a project that fetches data from a public API such as weather forecast or news articles

  • Use libraries like Axios or Fetch API to make API calls

  • Display the fetched data in a user-friendly interface

  • Implement error handling for failed API calls

Add your answer

Q11. 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

Ans.

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.

Add your answer

Q12. Maximum Depth of a Binary Tree Problem Statement

Given the root node of a binary tree with N nodes, where each node contains integer values, determine the maximum depth of the tree. The depth is defined as the ...read more

Ans.

Find the maximum depth of a binary tree given its level order traversal.

  • Traverse the tree level by level and keep track of the depth using a queue data structure.

  • For each level, increment the depth by 1 until all nodes are processed.

  • Return the maximum depth encountered during traversal as the final result.

  • Example: For input [5, 10, 15, 20, -1, 25, 30, -1, 40, -1, -1, -1, -1, 45], the maximum depth is 7.

Add your answer

Q13. Sliding Window Maximum Problem Statement

You are given an array/list of integers with length 'N'. A sliding window of size 'K' moves from the start to the end of the array. For each of the 'N'-'K'+1 possible wi...read more

Ans.

Sliding window maximum problem where we find maximum element in each window of size K.

  • Use a deque to store indices of elements in decreasing order within the window.

  • Pop elements from the deque that are out of the current window.

  • Add the maximum element to the result for each window.

Add your answer

Q14. 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

Ans.

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.

Add your answer

Q15. 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
Ans.

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.

Add your answer

Q16. Maximum Number With Single Swap

You are given an array of N elements that represent the digits of a number. You can perform one swap operation to exchange the values at any two indices. Your task is to determin...read more

Ans.

Given an array of digits, find the maximum number that can be achieved by performing at most one swap.

  • Iterate through the array to find the maximum digit.

  • If the maximum digit is already at the beginning, find the next maximum digit and swap them.

  • If the maximum digit is not at the beginning, swap it with the digit at the beginning.

Add your answer

Q17. 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

Ans.

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.

Add your answer

Q18. String Transformation Problem

Given a string (STR) of length N, you are tasked to create a new string through the following method:

Select the smallest character from the first K characters of STR, remove it fr...read more

Ans.

Given a string, select smallest character from first K characters, remove it, and append to new string until original string is empty.

  • Iterate through the string, selecting the smallest character from the first K characters each time.

  • Remove the selected character from the original string and append it to the new string.

  • Repeat the process until the original string is empty.

  • Return the final new string formed after the operations.

Add your answer

Q19. Equilibrium Index Problem Statement

Given an array Arr consisting of N integers, your task is to find the equilibrium index of the array.

An index is considered as an equilibrium index if the sum of elements of...read more

Ans.

Find the equilibrium index of an array where sum of elements on left equals sum on right.

  • Iterate through the array and calculate prefix sum and suffix sum at each index.

  • Compare prefix sum and suffix sum to find equilibrium index.

  • Return the left-most equilibrium index found.

Add your answer

Q20. 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

Ans.

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

Add your answer

Q21. System Design round - Designing solution

Ans.

Design a scalable and fault-tolerant system for a social media platform

  • Use microservices architecture to break down the system into smaller, independent services

  • Implement load balancing to distribute traffic evenly across servers

  • Utilize caching mechanisms to improve performance and reduce database load

  • Implement redundancy and failover mechanisms to ensure high availability

  • Use monitoring and alerting tools to detect and respond to issues proactively

Add your answer

Q22. 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

Ans.

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

Add your answer

Q23. Design calculator app

Ans.

Design a calculator app with basic arithmetic operations.

  • Include basic arithmetic operations like addition, subtraction, multiplication, and division.

  • Design a user-friendly interface with large buttons for numbers and operations.

  • Allow users to input numbers using both keypad and touch screen.

  • Implement error handling for division by zero and other invalid inputs.

Add your answer

Q24. design url shortener

Ans.

Design a URL shortener system

  • Generate a unique short code for each URL

  • Store the mapping of short code to original URL in a database

  • Redirect users from short URL to original URL

  • Consider scalability and performance

  • Implement analytics to track usage statistics

Add your answer

Q25. How can improve the sales and marketing what is your projection What is the reporting procedure

Ans.

To improve sales and marketing, I would focus on creating targeted campaigns and utilizing data analytics to track performance.

  • Conduct market research to identify target audience and their needs

  • Develop targeted campaigns with clear messaging and call-to-action

  • Utilize data analytics to track campaign performance and make adjustments as needed

  • Collaborate with sales team to ensure alignment and provide necessary support

  • Regularly review and update marketing strategies based on ma...read more

Add your answer

Q26. Sql queries to find 2 max salary

Ans.

Use SQL query to find the top 2 highest salaries in a table.

  • Use the ORDER BY clause to sort the salaries in descending order.

  • Use the LIMIT clause to limit the results to 2.

  • Example: SELECT salary FROM employees ORDER BY salary DESC LIMIT 2;

Add your answer

Q27. Logical coding to write power base 10

Ans.

To write power base 10 in logical coding, you can simply use the exponentiation operator or function.

  • Use the exponentiation operator '**' in Python to calculate power base 10.

  • In JavaScript, you can use the Math.pow() function to calculate power base 10.

  • In Java, you can use the Math.pow() function as well to calculate power base 10.

Add your answer

Q28. what do think about women's education?

Ans.

Women's education is crucial for the development of society and the empowerment of women.

  • Women's education leads to better health outcomes for themselves and their families.

  • Educated women are more likely to participate in the workforce and contribute to the economy.

  • Education can help women gain the skills and knowledge needed to advocate for their rights and challenge gender inequality.

  • Investing in women's education has been shown to have a positive impact on reducing poverty...read more

Add your answer

Q29. Design a whole application in fiori

Add your answer

Q30. how do you problem solve?

Ans.

I approach problem solving by breaking down the issue, analyzing possible solutions, and implementing the best course of action.

  • Identify the problem and gather relevant information

  • Brainstorm potential solutions

  • Evaluate each solution based on feasibility and effectiveness

  • Implement the chosen solution and monitor outcomes

  • Adjust the approach if needed

Add your answer

Q31. Design Walmart search API

Ans.

Design Walmart search API

  • Define search parameters (e.g. product name, category, price range)

  • Implement search algorithm (e.g. keyword matching, relevance ranking)

  • Integrate with Walmart's product database

  • Provide filtering and sorting options

  • Ensure scalability and performance

  • Include error handling and logging

Add your answer

Q32. Explain Inheritance in C++

Ans.

Inheritance in C++ allows a class to inherit properties and behavior from another class.

  • Inheritance allows for code reusability by creating a new class based on an existing class.

  • Derived class inherits attributes and methods from the base class.

  • Types of inheritance include single, multiple, multilevel, and hierarchical.

  • Example: class Animal is a base class, class Dog is a derived class inheriting from Animal.

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at ANSR Source

based on 24 interviews
Interview experience
4.1
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

3.7
 • 262 Interview Questions
4.0
 • 240 Interview Questions
4.2
 • 239 Interview Questions
3.8
 • 211 Interview Questions
4.0
 • 158 Interview Questions
View all
Top Walmart Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter