Check whether a string is a palindrome while ignoring spaces, punctuation and case, using two pointers in O(n) time and O(1) space.
Interview Insights and Technical Explorations
Check whether a string is a palindrome while ignoring spaces, punctuation and case, using two pointers in O(n) time and O(1) space.
Print the Fibonacci series with a loop, a recursive version, why plain recursion is exponential, and how memoisation fixes it.
Move all zeros to the end of an array in place, keeping the order of the other elements, in one pass with O(1) extra space.
Find the first character that appears only once in a string, in two passes with a count array or LinkedHashMap, with complexity and edge cases.
Check whether two strings are anagrams with a 26-count array in O(n), the sorting approach, a HashMap for Unicode, and how to ignore spaces and case.
Find the second largest element of an array in a single pass, handling duplicates, negative numbers and arrays with fewer than two distinct values.
Reverse a string in Java without StringBuilder.reverse(): the two-pointer swap, building a new string, recursion, and the Unicode edge case interviewers like.
Check whether a number is prime in Java: the simple version, the square-root version, skipping even numbers, the 6k ± 1 trick, and the Sieve of Eratosthenes for many numbers.