PhonePe Interview Questions
Showing 98 questions
Determine if an input string matches a given regular expression that supports '.' and '*' characters. The '.' matches any single character, and '*' matches zero or more occurrences of the preceding element.
#1. Regular Expression Matching
Given a string of digits, remove *k* digits to obtain the smallest possible number. You need to determine which digits to remove to minimize the resulting number.
#2. Remove K Digits
You have K sorted lists of numbers. Find the smallest range [min, max] that includes at least one number from each of the K lists.
#3. Smallest Range Covering Elements from K Lists
You are given a list of candies with different tastiness values. Choose a candy basket such that the minimum tastiness difference between any two candies in the basket is maximized.
#4. Maximum Tastiness of Candy Basket
Simulate a simple bank system that supports basic operations like deposit, withdraw, and check balance for different accounts. You will implement methods to handle these transactions and ensure validity based on account balances and existence.
#5. Simple Bank System
You're given a string and a list of index pairs. You can swap characters at these indices any number of times. Find the lexicographically smallest string you can obtain after performing these swaps.
#6. Smallest String With Swaps
A robot collects money from houses on a street, but an alarm will sound if it robs two adjacent ones. Given the amounts of money in each house, find the maximum total amount the robot can collect without setting off the alarm.
#7. Maximum Amount of Money Robot Can Earn
Given a large sequence and a smaller subsequence, find all the shortest supersequences that contain the subsequence. Return the frequencies of each unique character within these shortest supersequences.
#8. Frequencies of Shortest Supersequences
You start at a point on an infinite grid and can move to adjacent coordinates or double your current coordinates. Determine if you can reach a given target point using these moves.
#9. Check if Point Is Reachable
You're given a string and two patterns. Find all 'beautiful' indices where an occurrence of the first pattern is within 'k' distance of an occurrence of the second pattern.
#10. Find Beautiful Indices in the Given Array II
Determine how many arrays of a specific length can be formed where exactly 'k' pairs of adjacent elements are identical. The array elements must be within a defined range.
#11. Count the Number of Arrays with K Matching Adjacent Elements
Given an array representing the height of bars, calculate how much water can be trapped between them after rain. Think about finding the maximum height to the left and right of each bar.
#12. Trapping Rain Water
You're given an array representing bloom days for flowers. Find the minimum number of days needed to create a certain number of bouquets, given each bouquet needs a specific number of adjacent flowers.
#13. Minimum Number of Days to Make m Bouquets
Find the longest palindromic substring within a given string. A palindromic substring reads the same forwards and backward.
#14. Longest Palindromic Substring
Imagine stones on a grid. You can remove stones if they share a row or column with another stone. Find the maximum number of stones you can remove.
#15. Most Stones Removed with Same Row or Column
You're given a list of jobs with start times, end times, and profits. Find the maximum profit you can obtain by scheduling a subset of jobs that don't overlap.
#16. Maximum Profit in Job Scheduling
You are a robber planning to rob houses along a street. Maximize your loot, but be careful - adjacent houses have connected security systems that will trigger an alarm if you rob them both.
#17. House Robber
Imagine a tree structure where each node represents a city. Calculate the sum of distances from each city to all other cities in the tree.
#18. Sum of Distances in Tree
You are given an array where each element represents the maximum jump length from that position. Find the minimum number of jumps required to reach the last index.
#19. Jump Game II
Imagine you're planning a trip using a network of bus routes. Given a set of routes and start/end locations, find the fewest number of buses you must take to reach your destination.
#20. Bus Routes