Check if a matrix is a Toeplitz or not
Given an N × N matrix, check if it is a Toeplitz matrix or not. A Toeplitz matrix or diagonal-constant matrix is a matrix in which each descending diagonal from left to right is constant.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an N × N matrix, check if it is a Toeplitz matrix or not. A Toeplitz matrix or diagonal-constant matrix is a matrix in which each descending diagonal from left to right is constant.
Write an efficient algorithm to print the two-dimensional view of a binary tree.
Given an integer array between 0 and 9, find two numbers with maximum sum formed using all the array digits. The difference in the number of digits of the two numbers should be ± 1.
Given a collection of n items, each of which has a non-negative integer key whose maximum value is at most k, effectively sort it using the counting sort algorithm.
Given a string, remove adjacent duplicates characters from it. In other words, remove all consecutive same characters except one.
Given two arrays of positive integers, add their elements into a new array. The solution should add both arrays, one by one starting from the 0th index, and split the sum into individual digits if it is a 2–digit number
Given a huge set of words with duplicates present, find the maximum occurring word in it. If two words have the same count, return any one of them.
Quicksort performance can be boosted in several ways. In this post, we will cover a few of them.
Given an integer array, find a contiguous subarray within it that has the largest sum using Kadane’s algorithm.
Given an integer array, find the maximum product of two integers in it. For example, consider array {-10, -3, 5, 6, -2}. The maximum product is the (-10, -3) or (5, 6) pair.
Given an integer array, move all zeros present in it to the end. The solution should maintain the relative order of items in the array and should not use constant space.
Given an integer array containing duplicates, return the majority element if present. A majority element appears more than n/2 times, where n is the array size.