Microsoft Previous Year Coding Questions 2025

Microsoft, one of the world’s leading tech giants, is renowned for its rigorous and comprehensive interview process, designed to identify top talent in software engineering. Preparing for a Microsoft coding interview requires a strong grasp of data structures, algorithms, and problem-solving skills. This blog provides a curated list of commonly asked Microsoft coding questions, complete with problem statements and examples, to help you excel in your preparation. Whether you're aiming for a software engineer, data scientist, or other technical role, mastering these problems will give you a competitive edge.

Understanding Microsoft’s Hiring Process

Microsoft’s hiring process for technical roles, such as software engineer or data scientist, typically involves multiple stages designed to evaluate your technical expertise, problem-solving ability, and cultural fit. Below is a breakdown of the standard hiring process:

  1. Application Submission:

    • Candidates apply through Microsoft’s career portal (careers.microsoft.com) or via referrals, campus recruitment, or job boards like LinkedIn.
    • Tailor your resume to highlight relevant technical skills, projects, and experience in data structures, algorithms, and programming languages like C++, Java, or Python.
  2. Online Coding Assessment:

    • Shortlisted candidates are invited to an online coding round, often conducted via platforms like CoCubes, HackerRank, or Microsoft’s proprietary system.
    • This round typically includes 1–3 coding questions to be solved within 60–90 minutes, focusing on data structures (arrays, linked lists, trees, graphs) and algorithms (sorting, searching, dynamic programming).
    • Questions range from easy to medium difficulty, testing your ability to write efficient, bug-free code.
  3. Phone/Video Screening:

    • Candidates who pass the online assessment proceed to a phone or video interview with a Microsoft engineer.
    • This round involves 1–2 coding problems solved on a shared coding platform or whiteboard, with an emphasis on explaining your thought process.
    • Behavioral questions may also be asked to assess communication skills and alignment with Microsoft’s values.
  4. On-Site/Virtual Interview Rounds:

    • Successful candidates are invited to multiple rounds (typically 4–5) of technical interviews, either on-site at a Microsoft office or virtually.
    • Each round focuses on different aspects, such as:
      • Coding: Solve complex problems involving data structures, algorithms, or system design.
      • System Design: Design scalable systems (e.g., a messaging app or cloud service), emphasizing architecture and trade-offs (more common for senior roles).
      • Behavioral: Questions like “Tell me about a time you faced a challenge” to evaluate teamwork, leadership, and problem-solving.
      • Technical Deep Dive: Discuss past projects, technical decisions, and domain-specific knowledge.
    • Interviewers assess code efficiency, clarity of explanation, and handling of edge cases.
  5. Hiring Decision:

    • After the interviews, the hiring team reviews feedback from all interviewers to make a final decision.
    • Successful candidates receive an offer, which includes details on role, compensation, and benefits. Microsoft is known for competitive packages, including stock options and bonuses.
    • If not selected, candidates may receive feedback and can reapply after a cooling-off period (typically 6–12 months).

How to Use This Resource

The following list includes coding questions reportedly asked in Microsoft’s previous year interviews, covering a wide range of topics and difficulty levels. Each problem includes a clear problem statement and example to guide your understanding. Practice these on platforms like LeetCode, HackerRank, or CodeChef to simulate the coding environment. Focus on explaining your thought process clearly, as Microsoft interviewers value both correctness and communication.

Additional Resources for Preparation

To maximize your chances of success, complement this question list with the following resources:

Tips for Success

  • Understand the Fundamentals: Be proficient in data structures (arrays, linked lists, stacks, queues, trees, graphs) and algorithms (greedy, dynamic programming, binary search).
  • Optimize Your Solutions: Aim for efficient time and space complexity, as Microsoft emphasizes optimized code.
  • Practice Communication: Be ready to explain your approach clearly during interviews.
  • Mock Interviews: Use platforms like Pramp or Interviewing.io to simulate real interview scenarios.
  • Time Management: Practice solving problems within 60 minutes, as Microsoft’s coding rounds often have tight time limits.

Practice the questions below to start your preparation journey. Good luck, and happy coding!


Microsoft Previous Year Coding Questions

Below is a comprehensive list of coding questions reportedly asked in Microsoft's previous year coding rounds, including online assessments and technical interviews. Each problem includes a clear problem statement and example. The questions cover various topics such as arrays, linked lists, trees, strings, dynamic programming, and more.


1. Two Sum

Problem Statement: Given an array of integers and a target value, determine if there are any two integers in the array whose sum equals the given value. Return true if the sum exists, false otherwise. You may not use the same element twice, and the answer can be returned in any order.
Example:
Input: nums = [2, 7, 11, 15], target = 9
Output: [0, 1] (because nums[0] + nums[1] = 2 + 7 = 9)


2. Set Rows and Columns to Zero

Problem Statement: Given a two-dimensional array (matrix), if any element is zero, set its entire row and column to zero.
Example:
Input: matrix = [[0, 2, 3, 4], [5, 6, 0, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
Output: [[0, 0, 0, 0], [0, 6, 0, 8], [0, 10, 0, 12], [0, 14, 0, 16]]
Explanation: Zeros at positions (0,0) and (1,2) cause their respective rows and columns to be set to zero.


3. Add Two Numbers Represented by Linked Lists

Problem Statement: Given the head pointers of two linked lists where each linked list represents an integer number (each node is a digit, with the first node as the least significant digit), add the numbers and return the resulting linked list.
Example:
Input: l1 = 8 -> 4 -> 7 (748), l2 = 9 -> 0 -> 3 -> 6 (6309)
Output: 7 -> 5 -> 0 -> 7 (7057, since 748 + 6309 = 7057)


4. Copy Linked List with Arbitrary Pointer

Problem Statement: Given a linked list where each node has two pointers—next (regular pointer) and arbitrary_pointer (can point to any node in the list)—create a deep copy of the linked list. The deep copy should be independent, meaning operations on the original list (inserting, modifying, removing) should not affect the copied list.
Example:
Input: Linked list with nodes [1, 2, 3, 4, 5] and arbitrary pointers (e.g., 1->3, 2->1, 3->5, 4->3, 5->2)
Output: A new linked list with the same structure and arbitrary pointer connections.


5. Level Order Traversal of Binary Tree

Problem Statement: Given the root of a binary tree, display the node values at each level (level-order traversal). Return the result as a list of lists, where each inner list contains the node values at a particular level.
Example:
Input: Binary tree with root = 5, left = 9, right = 12, right.left = 25, right.right = 7
Output: [[5], [9, 12], [25, 7]]


6. Connect Sibling Pointers in Binary Tree

Problem Statement: Given a binary tree, connect the sibling pointer of each node to the next node at the same level. The last node in each level should point to the first node of the next level.
Example:
Input: Binary tree with nodes [1, 2, 3, 4, 5]
Output: Nodes connected such that 1->2, 2->3, 3->4, 4->5, 5->null


7. Find Missing Number in Array

Problem Statement: Given an array of positive numbers from 1 to n, where all numbers except one (x) are present, find the missing number x. The array is unsorted.
Example:
Input: nums = [1, 2, 4, 5, 6, 7, 8], n = 8
Output: 6


8. Merge Two Sorted Linked Lists

Problem Statement: Write a function that takes two sorted linked lists and merges them into a single sorted linked list by splicing their nodes together.
Example:
Input: l1 = 1 -> 2 -> 4, l2 = 3 -> 5 -> 6
Output: 1 -> 2 -> 3 -> 4 -> 5 -> 6


9. Check if Binary Tree is Symmetric

Problem Statement: Given a binary tree, determine if it is a mirror image of itself (symmetric). Return true if symmetric, false otherwise.
Example:
Input: Tree with root = 1, left = 2, right = 2, left.left = 3, left.right = 4, right.left = 4, right.right = 3
Output: true


10. Reverse Words in a Sentence

Problem Statement: Reverse the order of words in a given sentence.
Example:
Input: "sphinx of black quartz judge my vow"
Output: "vow my judge quartz black of sphinx"


11. Find All Palindrome Substrings

Problem Statement: Given a string, find all non-single-letter substrings that are palindromes.
Example:
Input: "poppopo"
Output: ["pop", "opo", "oppo", "poppop"]


12. String Segmentation

Problem Statement: Given a dictionary of words and a large input string, determine if the input string can be completely segmented into words from the dictionary.
Example:
Input: s = "applepenapple", dictionary = ["apple", "pen"]
Output: true (because "applepenapple" can be segmented as "apple pen apple")


13. Find Maximum Single Sell Profit

Problem Statement: Given a list of daily stock prices (integers), return the buy and sell prices that maximize the profit from a single buy/sell transaction. If no profit is possible, minimize the loss.
Example:
Input: prices = [7, 1, 5, 3, 6, 4]
Output: Buy at 1, sell at 6 (profit = 5)


14. Length of Longest Subsequence (Increasing then Decreasing)

Problem Statement: Given a one-dimensional integer array of length n, find the length of the longest subsequence that increases before decreasing.
Example:
Input: arr = [1, 2, 3, 2, 1]
Output: 5 (the entire array is a valid subsequence)


15. Longest Path in Matrix

Problem Statement: Given an nn matrix where all numbers are distinct, find the longest path starting from any cell such that all cells along the path increase in order by 1.
*Example
:
Input: matrix = [[1, 2, 9], [5, 3, 8], [4, 6, 7]]
Output: 6 (path: 1 -> 2 -> 3 -> 4 -> 5 -> 6)


16. Find All Sum Combinations

Problem Statement: Given a positive integer target, print all possible combinations of positive integers that sum up to the target.
Example:
Input: target = 5
Output: [[1, 4], [2, 3], [1, 1, 3], [1, 2, 2], [1, 1, 1, 2], [1, 1, 1, 1, 1]]


17. Find Kth Permutation

Problem Statement: Given a set of n variables, find the kth permutation of those variables.
Example:
Input: n = 3, k = 3
Output: "213" (the 3rd permutation of [1, 2, 3])


18. Regular Expression Matching

Problem Statement: Given a text and a pattern, determine if the pattern matches the text completely using regular expression matching. The pattern contains only two operators: . (matches any single character) and * (the preceding character may appear zero or more times).
Example:
Input: text = "aab", pattern = "c*a*b"
Output: true


19. Rat in a Maze

Problem Statement: A rat is placed at position (0,0) in a square nn matrix. Find all possible paths to reach the destination (n-1, n-1). The rat can move vertically or horizontally, only through cells with value 1 (traversable), and cannot visit a cell more than once. Cells with value 0 are impassable.
*Example
:
Input: matrix = [[1, 0, 0], [1, 1, 0], [0, 1, 1]]
Output: Paths like [(0,0), (1,0), (1,1), (2,1)]


20. Solve the Sudoku

Problem Statement: Given a 99 square matrix representing an incomplete Sudoku puzzle, return true if the puzzle can be completed and provide the completed grid. Otherwise, return false.
*Example
:
Input: grid = [[5,3,.,.,7,.,.,.,.], ...] (partial Sudoku grid)
Output: true (with completed grid) or false


21. Clone a Directed Graph

Problem Statement: Given the root node of a directed graph, create a deep copy of the graph with the same vertices and edges.
Example:
Input: Graph with nodes [1, 2, 3] and edges [1->2, 2->3, 3->1]
Output: A new graph with identical structure


22. Breadth-First Traversal of a Graph

Problem Statement: Starting from a source node, traverse a given graph breadthwise to find the distance between the source node and node n.
Example:
Input: Graph with nodes [1, 2, 3, 4], edges [1->2, 2->3, 3->4], source = 1, target = 4
Output: 3 (distance from 1 to 4)


23. Check Path from Source to Destination

Problem Statement: Given an nn graph where each cell contains a value (0 = source, 1 = wall, 2 = blank, 3 = destination), determine if there is a path from the source to the destination. The graph can be traversed horizontally and vertically.
*Example
:
Input: graph = [[0, 2, 2], [1, 1, 2], [2, 2, 3]]
Output: true (path exists from (0,0) to (2,2))


24. Find Closest Meeting Point

Problem Statement: Given n people on a square grid, find the point that requires the least total distance for all people to meet at that point.
Example:
Input: grid = 5x5 with people at positions [(0,0), (1,1), (2,2)]
Output: (1,1) (minimizes total Manhattan distance)


25. Search in a Sorted 2D Matrix

Problem Statement: Given a two-dimensional array where all elements in each row and column are sorted, find the position of a given key.
Example:
Input: matrix = [[1, 3, 5], [2, 6, 9], [7, 8, 10]], key = 6
Output: (1,1)


26. Check if Binary Tree is BST

Problem Statement: Given a binary tree, determine if it is a valid Binary Search Tree (BST).
Example:
Input: Tree with root = 2, left = 1, right = 3
Output: true


27. Remove Duplicates from String In-Place

Problem Statement: Remove duplicates from a string in-place.
Example:
Input: "abbaca"
Output: "abca"


28. Search in Rotated Sorted Array

Problem Statement: Given a rotated sorted array (unique elements), search for a target element.
Example:
Input: nums = [4, 5, 6, 7, 0, 1, 2], target = 0
Output: 4 (index of 0)


29. Print Last 10 Lines of a Big File

Problem Statement: Given a large file or string, print the last 10 lines.
Example:
Input: A file with 100 lines
Output: Lines 91 to 100


30. Connect Nodes at Same Level

Problem Statement: Connect nodes at the same level in a binary tree using a next pointer.
Example:
Input: Binary tree with nodes [1, 2, 3, 4, 5]
Output: Nodes connected such that 2->3, 4->5, etc.


31. Least Common Ancestor in Binary Tree

Problem Statement: Find the least common ancestor of two nodes in a binary tree or BST.
Example:
Input: Tree with root = 3, nodes = 5, 1
Output: 3 (LCA of 5 and 1)


32. Run Length Encoding

Problem Statement: Implement run-length encoding for a given string.
Example:
Input: "AAABBBCC"
Output: "A3B3C2"


33. Detect Cycle in Linked List

Problem Statement: Determine if a linked list contains a cycle.
Example:
Input: Linked list with nodes [3, 2, 0, -4], where -4 points back to 2
Output: true


34. Correct Swapped Nodes in BST

Problem Statement: Two nodes in a Binary Search Tree are swapped. Correct the BST to restore its properties.
Example:
Input: BST with nodes [3, 5, 2] (where 5 and 2 are swapped)
Output: Corrected BST [3, 2, 5]


35. Word Wrap

Problem Statement: Given a sequence of words and a maximum line width, format the text such that each line has at most the given width and words are not split.
Example:
Input: words = ["This", "is", "an", "example"], width = 7
Output: ["This is", "an", "example"]


36. Shortest Path in Unweighted Graph

Problem Statement: Find the shortest path from a source to a destination in an unweighted graph.
Example:
Input: Graph with nodes [1, 2, 3, 4], edges [1->2, 2->3, 3->4], source = 1, destination = 4
Output: 3 (path length)


37. Node Level in Binary Tree

Problem Statement: Given a binary tree and a node, find the level of that node.
Example:
Input: Tree with root = 1, node = 3 (at level 2)
Output: 2


38. Sum at Kth Level

Problem Statement: Find the sum of node values at the kth level of a binary tree.
Example:
Input: Tree with root = 1, level 2 = [2, 3], k = 2
Output: 5 (2 + 3)


39. Compress the String

Problem Statement: Compress a string by replacing repeated characters with their count.
Example:
Input: "aabcccccaaa"
Output: "a2b1c5a3"


40. Convert Binary Tree to Doubly Linked List

Problem Statement: Convert a given binary tree to a doubly linked list using in-order traversal.
Example:
Input: Binary tree with in-order [4, 2, 5, 1, 3]
Output: Doubly linked list 4 <-> 2 <-> 5 <-> 1 <-> 3


41. Longest Mountain Subarray

Problem Statement: Find the length of the longest subarray that forms a mountain (increases then decreases).
Example:
Input: arr = [2, 1, 4, 7, 3, 2, 5]
Output: 5 (subarray [1, 4, 7, 3, 2])


42. Kth Smallest Element

Problem Statement: Find the kth smallest element in an unsorted array.
Example:
Input: arr = [7, 10, 4, 3, 20, 15], k = 3
Output: 7


43. Swap Numbers Without Temporary Variable

Problem Statement: Swap two numbers without using a temporary variable.
Example:
Input: a = 5, b = 10
Output: a = 10, b = 5


44. Minimum Steps to Reach Target by a Knight

Problem Statement: Find the minimum number of steps for a knight to reach a target position on a chessboard.
Example:
Input: start = (0,0), target = (2,2)
Output: 2


45. Diagonal Traversal of Matrix

Problem Statement: Traverse a matrix diagonally and return the elements in diagonal order.
Example:
Input: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Output: [1, 2, 4, 7, 5, 3, 6, 8, 9]


46. Find All Triplets with Zero Sum

Problem Statement: Find all triplets in an array that sum to zero.
Example:
Input: arr = [-1, 0, 1, 2, -1, -4]
Output: [[-1, 0, 1], [-1, 2, -1]]


47. Total Area of Overlapping Rectangles

Problem Statement: Given a list of rectangles (defined by bottom-left and top-right coordinates), find the total area of the overlapping regions.
Example:
Input: rectangles = [[0,0,2,2], [1,1,3,3]]
Output: 7


48. Longest Palindromic Subsequence

Problem Statement: Find the length of the longest palindromic subsequence in a string.
Example:
Input: s = "bbbab"
Output: 4 (e.g., "bbbb")


49. Nth Element of Modified Fibonacci Series

Problem Statement: Find the nth element of a modified Fibonacci series where each element is the sum of the previous three elements.
Example:
Input: n = 5, series starts as [0, 1, 1]
Output: 5 (series: 0, 1, 1, 2, 4, 5)


50. Palindrome Partitioning

Problem Statement: Partition a string such that every substring in the partition is a palindrome. Return all possible partitions.
Example:
Input: s = "aab"
Output: [["a", "a", "b"], ["aa", "b"]]


51. Dice Throws

Problem Statement: Given n dice and a target sum, find the number of ways to achieve the target sum by throwing the dice.
Example:
Input: n = 2, target = 7
Output: 6 (e.g., (1,6), (2,5), (3,4), (4,3), (5,2), (6,1))


52. Reverse a String

Problem Statement: Reverse a given string.
Example:
Input: "hello"
Output: "olleh"


53. Find Largest Element in Array

Problem Statement: Find the largest element in an array.
Example:
Input: arr = [10, 5, 20, 8]
Output: 20


Problem Statement: Implement a binary search algorithm to find a target in a sorted array.
Example:
Input: arr = [2, 3, 4, 10, 40], target = 10
Output: 3 (index of 10)


55. Check if String is Palindrome

Problem Statement: Check if a given string is a palindrome.
Example:
Input: "racecar"
Output: true


56. Sort Array Using Bubble Sort

Problem Statement: Sort an array using the bubble sort algorithm.
Example:
Input: arr = [64, 34, 25, 12, 22]
Output: [12, 22, 25, 34, 64]


57. Find Second Smallest Element in Array

Problem Statement: Find the second smallest element in an array.
Example:
Input: arr = [12, 13, 1, 10, 34]
Output: 10


58. Count Frequency of Elements in Array

Problem Statement: Count the frequency of each element in an array.
Example:
Input: arr = [1, 2, 2, 3, 1]
Output: {1: 2, 2: 2, 3: 1}


59. Implement Stack Using Array

Problem Statement: Implement a stack data structure using an array.
Example:
Operations: push(1), push(2), pop(), push(3)
Output: Stack = [1, 3]


60. Find Minimum Element in Rotated Sorted Array

Problem Statement: Find the minimum element in a rotated sorted array.
Example:
Input: arr = [4, 5, 6, 7, 0, 1, 2]
Output: 0


61. Check if Two Strings are Anagrams

Problem Statement: Check if two strings are anagrams of each other.
Example:
Input: s1 = "listen", s2 = "silent"
Output: true


62. Implement Queue Using Two Stacks

Problem Statement: Implement a queue using two stacks.
Example:
Operations: enqueue(1), enqueue(2), dequeue(), enqueue(3)
Output: Queue = [2, 3]


63. Find Longest Common Prefix

Problem Statement: Find the longest common prefix in an array of strings.
Example:
Input: strs = ["flower", "flow", "flight"]
Output: "fl"


64. Find Maximum Depth of Binary Tree

Problem Statement: Find the maximum depth of a binary tree.
Example:
Input: Tree with root = 1, left = 2, right = 3, left.left = 4, left.right = 5
Output: 3


65. Reverse an Integer

Problem Statement: Reverse a given integer. Handle overflow cases.
Example:
Input: x = 123
Output: 321


66. Count Character Occurrences in String

Problem Statement: Count the number of occurrences of a character in a string.
Example:
Input: s = "hello", char = 'l'
Output: 2


67. Implement Hash Table

Problem Statement: Implement a hash table with basic operations (insert, search, delete).
Example:
Operations: insert(1, "one"), insert(2, "two"), search(1)
Output: "one"


68. Find Median of Two Sorted Arrays

Problem Statement: Given two sorted arrays, find the median of the combined array in logarithmic time.
Example:
Input: nums1 = [1, 3], nums2 = [2]
Output: 2.0


69. Implement Priority Queue

Problem Statement: Implement a priority queue with operations (insert, extract-max/min).
Example:
Operations: insert(5), insert(3), extract-max()
Output: 5


70. Check if Number is Prime

Problem Statement: Check if a given number is prime.
Example:
Input: n = 17
Output: true


71. Remove Duplicates from Sorted Array

Problem Statement: Remove duplicates from a sorted array in-place.
Example:
Input: arr = [1, 1, 2, 2, 3]
Output: [1, 2, 3]


72. Implement Binary Tree

Problem Statement: Implement a binary tree with basic operations (insert, search, delete).
Example:
Operations: insert(5), insert(3), insert(7), search(3)
Output: true


73. Find Intersection of Two Linked Lists

Problem Statement: Find the intersection point of two linked lists.
Example:
Input: list1 = 1 -> 2 -> 3 -> 4, list2 = 9 -> 3 -> 4
Output: Node with value 3


74. Calculate Factorial

Problem Statement: Calculate the factorial of a given number.
Example:
Input: n = 5
Output: 120


75. Find First Non-Repeating Character

Problem Statement: Find the first non-repeating character in a string.
Example:
Input: s = "leetcode"
Output: 'l'


76. Implement Heap

Problem Statement: Implement a max or min heap with operations (insert, extract-max/min).
Example:
Operations: insert(5), insert(3), extract-max()
Output: 5


77. Find Maximum Subarray Sum

Problem Statement: Find the maximum sum of a contiguous subarray.
Example:
Input: arr = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output: 6 (subarray [4, -1, 2, 1])


78. Check Valid Parentheses Sequence

Problem Statement: Check if a string contains a valid sequence of parentheses.
Example:
Input: s = "({[]})"
Output: true


Problem Statement: Implement a depth-first search algorithm for a graph.
Example:
Input: Graph with nodes [1, 2, 3], edges [1->2, 2->3]
Output: Traversal order like [1, 2, 3]


80. Find Intersection of Two Arrays

Problem Statement: Find the intersection of two arrays (common elements).
Example:
Input: nums1 = [1, 2, 2, 1], nums2 = [2, 2]
Output: [2, 2]


Problem Statement: Implement a breadth-first search algorithm for a graph.
Example:
Input: Graph with nodes [1, 2, 3], edges [1->2, 2->3]
Output: Traversal order like [1, 2, 3]


82. Longest Substring Without Repeating Characters

Problem Statement: Given a string, find the length of the longest substring without repeating characters.
Example:
Input: s = "abcabcbb"
Output: 3 (substring "abc")


83. Merge Intervals

Problem Statement: Given an array of intervals [starti, endi], merge all overlapping intervals and return a new array of non-overlapping intervals.
Example:
Input: intervals = [[1, 3], [2, 6], [8, 10], [15, 18]]
Output: [[1, 6], [8, 10], [15, 18]]


84. Merge Sorted Arrays

Problem Statement: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. nums1 has enough space (size m+n) to hold all elements.
Example:
Input: nums1 = [4, 8, 9, 0, 0, 0], m = 3, nums2 = [1, 2, 7], n = 3
Output: [1, 2, 4, 7, 8, 9]


85. Number of Islands

Problem Statement: Given a 2D grid of 1s (land) and 0s (water), count the number of disconnected islands formed by connected land cells.
Example:
Input: grid = [[1, 1, 0], [1, 1, 0], [0, 0, 1]]
Output: 2


86. Single Number

Problem Statement: Given an array where every element appears twice except one, find the element that appears only once.
Example:
Input: nums = [4, 1, 2, 1, 2]
Output: 4


87. Frequency of Most Frequent Element

Problem Statement: Given an array and an integer k, find the maximum frequency of any element by incrementing elements at most k times.
Example:
Input: nums = [1, 2, 4], k = 5
Output: 3 (increment 1 and 2 to 4, frequency of 4 becomes 3)


88. Subarray Sum Equals K

Problem Statement: Given an array of integers and an integer k, find the total number of continuous subarrays that sum to k.
Example:
Input: nums = [1, 1, 1], k = 2
Output: 2 (subarrays [1, 1])


89. Move Zeroes

Problem Statement: Given an array, move all zeros to the end while maintaining the relative order of non-zero elements.
Example:
Input: nums = [0, 1, 0, 3, 12]
Output: [1, 3, 12, 0, 0]


90. Simple Addition Check

Problem Statement: Given two integers n and m, return n+m if the number of digits in n+m equals the number of digits in n; otherwise, return n.
Example:
Input: n = 123, m = 4
Output: 123 (since 123 + 4 = 127 has more digits than 123)


Join Telegram group for any doubts & discussions!

🧰 Useful Resources for Your Placement Prep