Reverse Nodes in k-Group

Problem Statement Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as …

Reverse Nodes in k-Group Read More »

Edit Distance

Problem Statement Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delete a character Replace a character Sample Test Cases Problem Solution We will be using Dynamic Programming Bottom-up approach. We can maintain …

Edit Distance Read More »

Find Index of zero to be replaced to get maximum length of consecutive ones

Given an array containing only zeros and ones, find the index of zero to be replaced with one to get the maximum length of consecutive ones. Test Case Example Input : 1 0 0 1 0 1Sample Output: 4 Test Case Explanation If we replace zero located at index 1, the maximum length of consecutive1s …

Find Index of zero to be replaced to get maximum length of consecutive ones Read More »

Longest Repeating Character

Longest Repeating Character Replacement Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string. In one operation, you can choose any character of the string and change it to any other uppercase English character. Find the length of the longest sub-string containing all repeating …

Longest Repeating Character Read More »

Finding kth smallest element in a sorted matrix

Problem Statement Given a sorted matrix of size n*n and a number k. Find the kth smallest element in the matrix. The matrix can contain duplicates. A sorted matrix is a matrix in which each row and each column is sorted. Example Test Case Given Matrix: 1 2 3 3 5 9 7 7 10 …

Finding kth smallest element in a sorted matrix Read More »

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]