Mastercard – Senior/Lead Java Software Engineer
Coding Interview Preparation
Core Data Structure Coding
• Two Sum – find two numbers that add to a target using HashMap (O(n)).
• Longest Substring Without Repeating Characters – sliding window.
• Merge Two Sorted Linked Lists.
• Reverse a Linked List (iterative and recursive).
• Detect Cycle in Linked List – Floyd’s slow/fast pointer.
Array / Sliding Window
• Maximum Subarray Sum (Kadane’s Algorithm).
• Product of Array Except Self (no division).
• Move Zeros to End.
• Find Missing Number using XOR or sum formula.
String Problems
• Valid Parentheses – stack.
• Group Anagrams – HashMap with sorted keys.
• String Compression.
• Longest Palindromic Substring.
Tree / Graph Coding
• Binary Tree Level Order Traversal (BFS).
• Lowest Common Ancestor in Binary Tree.
• Check if Binary Tree is Balanced.
• Number of Islands – DFS/BFS in grid.
HashMap / Frequency
• Top K Frequent Elements – heap or bucket sort.
• First Non-Repeating Character in String.
Concurrency (Senior Java)
• Print Odd/Even numbers using two threads.
• Producer–Consumer using BlockingQueue or wait/notify.
• Thread-safe Singleton using Double Checked Locking.
Low-Level Design Coding
• Implement LRU Cache with HashMap + Doubly Linked List (O(1)).
• Design a Rate Limiter (token bucket or sliding window).
• Design a URL Shortener encode/decode methods.
Payment / Transaction Style Problems
• Aggregate transactions and find top 3 users with highest spend.
• Detect fraud if a card has more than 3 transactions within 10 seconds.
• Log processing – find most active users in last 5 minutes.
Java-Specific Coding
• Custom Comparator to sort transactions by amount desc then timestamp.
• Java Stream API – find top 3 highest salaries.
Hard Problems
• Median of Two Sorted Arrays (logarithmic solution).
• Sliding Window Maximum.
• Merge K Sorted Lists using Min Heap.
Coding Interview Best Practices
• Clarify requirements before coding.
• Explain brute-force approach first.
• Optimize and discuss time/space complexity.
• Write clean, readable Java code.
• Test with edge cases.