Array and String Interview Questions (Easy,
Medium, Hard)
Array Questions
Easy (Array)
• Find the largest element in an array
• Find the smallest element
• Reverse an array
• Check if array is sorted
• Find the second largest element
• Count even and odd numbers
• Find the sum of all elements
• Move all zeros to the end
• Linear search in array
• Remove duplicates from a sorted array
Medium (Array)
• Two Sum problem
• Find the missing number (1 to n)
• Rotate array by K positions
• Merge two sorted arrays
• Find intersection of two arrays
• Find union of two arrays
• Kadane’s Algorithm (maximum subarray sum)
• Subarray with given sum
• Majority element (Moore’s Voting)
• Stock buy and sell problem
Hard (Array)
• Trapping Rain Water
• Maximum product subarray
• Median of two sorted arrays
• Longest consecutive sequence
• Count inversions in array
• Merge intervals
• Subarrays with XOR = K
• Next permutation
• Sliding window maximum
• Largest rectangle in histogram
String Questions
Easy (Strings)
• Reverse a string
• Check if a string is palindrome
• Count vowels and consonants
• Count frequency of each character
• Convert string to uppercase/lowercase
• Check if string contains only digits
• Remove spaces from string
• Find length of string (without inbuilt)
• Concatenate two strings
• Compare two strings
Medium (Strings)
• Check if two strings are anagrams
• Find first non-repeating character
• Remove duplicate characters
• Find all substrings
• String compression (aaabb → a3b2)
• Check if one string is rotation of another
• Find longest common prefix
• Convert string to integer (atoi)
• Group anagrams
• Longest substring without repeating characters
Hard (Strings)
• Minimum window substring
• Edit distance (Levenshtein distance)
• Wildcard pattern matching
• Regular expression matching
• Rabin–Karp string matching
• KMP algorithm (pattern searching)
• Longest palindromic substring
• Palindrome partitioning
• Word break problem
• Text justification
Apurva, you can do it ■■