# Category Archives: Python Programs

Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5… Read More
Number is represented in linked list such that each digit corresponds to a node in linked list. Add 1 to it. For example 1999 is… Read More
Given two lists sorted in increasing order, create and return a new list representing the intersection of the two lists. The new list should be… Read More
Given a singly linked list, find the middle of the linked list. For example, if the given linked list is 1->2->3->4->5 then the output should… Read More
Given an array of integers, and a number ‘sum’, find the number of pairs of integers in the array whose sum is equal to ‘sum’.… Read More
The atoi() function in C takes a string (which represents an integer) as an argument and returns its value of type int. So basically the… Read More
Given a list of integers, rearrange the list such that it consists of alternating minimum-maximum elements using only list operations. The first element of the… Read More
Given a linked list, rearrange it such that the converted list should be of the form a < b > c < d > e… Read More
Given a Linked List. The Linked List is in alternating ascending and descending orders. Sort the list efficiently.  Example:  Input List: 10 -> 40 ->… Read More
Depth First Traversal (or Search) for a graph is similar to Depth First Traversal of a tree. The only catch here is, unlike trees, graphs… Read More
Given a linked list, write a function to reverse every alternate k nodes (where k is an input to the function) in an efficient way.… Read More
Given a Romal numeral, the task is to find its corresponding decimal value. Example :  Input: IX Output: 9 IX is a Roman symbol which… Read More
Given a positive integer n which represents the dimensions of a 4n x 4n matrix with values from 1 to n filled from left to… Read More
Given a linked list, write a function to reverse every k nodes (where k is an input to the function).  Example:  Input: 1->2->3->4->5->6->7->8->NULL, K =… Read More
An array contains both positive and negative numbers in random order. Rearrange the array elements so that positive and negative numbers are placed alternatively. Number… Read More