Visa
10+ MarginEdge Interview Questions and Answers
Q1. Maximum Equal Elements After K Operations
You are provided with an array/list of integers named 'ARR' of size 'N' and an integer 'K'. Your task is to determine the maximum number of elements that can be made eq...read more
Determine the maximum number of elements that can be made equal by performing at most K operations on an array of integers.
Sort the array in non-decreasing order to easily identify the elements that need to be increased
Calculate the difference between adjacent elements to determine the number of operations needed to make them equal
Keep track of the total number of operations used and the maximum number of elements that can be made equal
Q2. Ninja's Dance Competition Pairing Problem
Ninja is organizing a dance competition and wants to pair participants using a unique method. Each participant chooses a number upon entry, and Ninja selects a number ‘...read more
Find the number of distinct pairs of participants with a given difference in chosen numbers.
Iterate through the array and for each element, check if the pair exists with the required difference 'K'.
Use a hash set to keep track of unique pairs to avoid counting duplicates.
Return the size of the hash set as the final count of distinct pairs.
Q3. Find Maximum Length Sub-array with Specific Adjacent Differences
Given an array of integers ‘A’ of length ‘N’, find the maximum length of a sub-array where the absolute difference between adjacent elements is e...read more
Find the maximum length of a sub-array with adjacent differences of 0 or 1 in an array of integers.
Iterate through the array and keep track of the current sub-array length with adjacent differences of 0 or 1.
Update the maximum length encountered so far as you traverse the array.
Return the maximum length found as the result.
Q4. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Design a Least Recently Used (LRU) cache data structure that supports get and put operations with capacity constraint.
Use a combination of hashmap and doubly linked list to implement the LRU cache.
Keep track of the least recently used item and evict it when the cache reaches its capacity.
Update the position of an item in the cache whenever it is accessed to maintain the order of recently used items.
Q5. Valid String Problem Statement
You are provided with a string S
containing only three types of characters: (')
, )')
, and *
.
Explanation:
A Valid String is characterized by the following conditions:
1. Each left...read more
Check if a given string containing parentheses and asterisks is valid based on certain conditions.
Iterate through the string and keep track of the count of left parentheses, right parentheses, and asterisks.
Use a stack to keep track of the positions of left parentheses and asterisks.
If at any point the count of right parentheses exceeds the count of left parentheses and asterisks, the string is invalid.
Q6. Count Pairs with Given Sum
Given an integer array/list arr
and an integer 'Sum', determine the total number of unique pairs in the array whose elements sum up to the given 'Sum'.
Input:
The first line contains ...read more
Count the total number of unique pairs in an array whose elements sum up to a given value.
Use a hashmap to store the frequency of each element in the array.
Iterate through the array and for each element, check if (Sum - current element) exists in the hashmap.
Increment the count of pairs if the complement exists in the hashmap.
Q7. Minimum Cost to Reach End Problem
You are provided with an array ARR
of integers of size 'N' and an integer 'K'. The goal is to move from the starting index to the end of the array with the minimum possible cos...read more
Find minimum cost to reach end of array by jumping with constraints
Use dynamic programming to keep track of minimum cost at each index
Iterate through the array and update the minimum cost based on reachable indices within K steps
Calculate cost to jump from current index to reachable indices and update minimum cost accordingly
Q8. What is race condition and how can it be eliminated
Race condition is a situation where multiple threads/processes access and manipulate shared data simultaneously.
It can be eliminated by using synchronization techniques like locks, semaphores, and mutexes.
Another way is to use atomic operations that ensure the data is accessed and modified atomically.
Using thread-safe data structures can also prevent race conditions.
Example: Two threads trying to increment a shared variable simultaneously can cause a race condition.
Example: U...read more
Q9. Explain Testing principles and Design principles
Testing principles ensure software quality, while design principles guide software development.
Testing principles include unit testing, integration testing, and acceptance testing.
Design principles include SOLID, DRY, and KISS.
Testing principles ensure that software meets requirements and is free of defects.
Design principles guide software development to be modular, maintainable, and scalable.
Q10. What is regression testing?
Regression testing is the process of testing changes made to a software application to ensure that existing functionality still works.
It is performed after making changes to the software
It ensures that existing functionality is not affected by the changes
It helps to catch any defects or bugs that may have been introduced
It can be automated using testing tools
Examples include retesting after bug fixes, testing after new features are added
Q11. What is JCube?
JCube is a Java library for creating and manipulating Rubik's Cube puzzles.
JCube provides classes for representing Rubik's Cube puzzles and algorithms for solving them.
It supports various cube sizes and can generate random scrambles.
JCube can be used in Java applications or as a standalone command-line tool.
It is open source and available on GitHub.
Q12. Software engineering principles
Software engineering principles are the best practices and guidelines for developing high-quality software.
Software should be designed with modularity and scalability in mind.
Code should be well-documented and easy to read.
Testing and debugging should be an integral part of the development process.
Version control should be used to manage code changes.
Security and privacy should be considered throughout the development lifecycle.
Q13. Code a circular linked list
A circular linked list is a data structure where the last node points back to the first node, forming a loop.
Create a Node class with data and next pointer
Initialize the head node and set its next pointer to itself
To add a node, create a new node and set its next pointer to the head node's next pointer, then update the head node's next pointer to the new node
To traverse the circular linked list, start from the head node and continue until reaching the head node again
Q14. Define Singleton class
A Singleton class is a class that can only have one instance at a time.
It restricts the instantiation of a class to a single object.
It provides a global point of access to that instance.
It is often used in situations where a single object is required to coordinate actions across a system.
Example: Database connection manager, Configuration manager, Logger manager.
Q15. Code a basic linked list
Code a basic linked list
Create a Node class with data and next pointer
Create a LinkedList class with head pointer
Implement methods to add, delete, and search nodes in the linked list
Q16. Code a basic binary tree
A binary tree is a data structure in which each node has at most two children.
Start with a root node
Each node has a left and right child
Nodes can be added or removed
Traversal can be done in-order, pre-order, or post-order
Q17. design google-pay
Design Google Pay - a digital wallet platform for online payments and transactions.
Allow users to securely store payment information such as credit/debit cards, bank accounts, and loyalty cards.
Enable users to make payments in stores, online, and within apps using their stored payment methods.
Implement security features like biometric authentication, tokenization, and encryption to protect user data.
Provide features for splitting bills, requesting money, and sending money to ...read more
Q18. HLD of recursive
High Level Design (HLD) of recursive functions in software development.
Recursive functions call themselves to solve smaller instances of the same problem.
HLD of recursive functions involves defining the base case, recursive case, and termination condition.
Example: HLD of a recursive function to calculate factorial of a number involves defining base case as factorial(0) = 1.
More about working at Visa
Top HR Questions asked in MarginEdge
Interview Process at MarginEdge
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month