Arrays

Search in a row and column-wise sorted matrix

Problem Statement: You have been given a 2-D array ‘mat’ of size ‘N x M’ where ‘N’ and ‘M’ denote the number of rows and columns, respectively. The elements of each row and each column are sorted in non-decreasing order.But, the first element of a row is not necessarily greater than the last element of the previous row (if it exists).You are given an … Read more

Convert an Array to a Doubly Linked List

Solution Disclaimer: Don’t jump directly to the solution, try it out yourself first. Intuition:  To convert an array to a doubly linked list, we can start by creating a new head node for the list. We can then iterate over the array, creating a new node for each element in the array.  As we create each … Read more

Convert an array to a Linked List

Approach: In order to convert an array to a linked list, start by defining a reference point. In this case, try to fix the start of the array, which will be the head of the linked list.  After fixing the head, iterate through the entire array, convert every element into a node of the linked List, and keep linking them. Algorithm: … Read more