## Rotate List Leetcode Solution

The problem Rotate List Leetcode Solution provides us a linked list and an integer. We are told to rotate the linked list to the right by k places. So if we rotate a linked list k places to the right, in each step we take the last element from the …

## Search in Rotated Sorted Array Leetcode Solution

Consider a sorted array but one index was picked and the array was rotated at that point. Now, once the array has been rotated you are required to find a particular target element and return its index. In case, the element is not present, return -1. The problem is generally …

## Maximum Product of Two Elements in an Array Leetcode Solution

In the problem “Maximum Product of Two Elements in an Array”, our goal is to find two indices i and j in a given array of integers a, such that the product (a[i] – 1) * (a[j] – 1) is maximum. The array has at least 2 elements and all …

## Scramble String

Problem Statement “Scramble String” problem states that you are given two strings. Check if the second string is a scrambled string of first one or not? Explanation Let string s = “great” Representation of s as binary tree by recursively dividing it into two non-empty sub-strings. This string can be …

## Convex Hull Algorithm

In problem “Convex Hull Algorithm” we have given a set of some points. The smallest polygon that can be formed with those points which contain all other points inside it will be called its convex hull. This can be achieved by using Jarvis Algorithm. Algorithm Initialize a leftmost point to …

## Longest Subarray Having Count of 1s One More than Count of 0s

We have given an array of integers. An array contains 1’s and 0’s only. The problem statement asks to find out the length of the longest Sub-Array which having the quantity of 1’s digit is just one more than the count of 0’s in a sub-array. Example Input: arr[] = …

## Longest subarray not having more than K distinct elements

The problem “Longest subarray not having more than K distinct elements” states that suppose you have an array of integers, the problem statement asks to find out the longest sub-array that having not greater than k different elements. Example arr[] = {4, 3, 5, 2, 1, 2, 0, 4, 5} …

## Find distance between two nodes of a Binary Tree

Problem Statement The problem “Find distance between two nodes of a Binary Tree” states that you are given a binary tree and you are given two nodes. Now you need to find the minimum distance between these two nodes. Example // Tree is shown using the image above node 1 …

## Binary Search Tree Delete Operation

Problem Statement The problem “Binary Search Tree Delete Operation” asks us to implement the delete operation for binary search tree. Delete function refers to the functionality to delete a node with a given key/data. Example Input Node to be deleted = 5 Output Approach for Binary Search Tree Delete Operation So …

## Best Time to Buy and Sell Stock

Problem Statement The problem “Best Time to Buy and Sell Stock” states that you are given an array of prices of length n, where the ith element stores the price of stock on ith day. If we can make only one transaction, that is, to buy on one day and …