Problem Statement Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string’s letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in . . . Read more

Problem Statement In an array, , the elements at indices and (where ) form an inversion if . In other words, inverted elements and are considered to be “out of order”. To correct an inversion, we can swap adjacent elements. For example, consider the dataset . It has two inversions: . . . Read more

Problem Statement You are given queries. Each query is of the form two integers described below: – : Insert x in your data structure. – : Delete one occurence of y from your data structure, if present. – : Check if any integer is present whose frequency is exactly . . . . Read more

You are given an array and you need to find number of tripets of indices such that the elements at those indices are in geometric progression for a given common ratio and . For example, . If , we have and at indices and . Function Description Complete the countTriplets . . . Read more

Problem Statement Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable . . . Read more

Problem Statement You are given an unordered array consisting of consecutive integers without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order. For example, given the array we perform the following steps: . . . Read more

Problem Statement Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he took, he noted if it was an uphill, , or a downhill, step. Gary’s hikes start and end . . . Read more

Problem Statement Create a stack data structure that supports the following operations as efficiently as possible: Push, which adds a new element atop the stack, Pop, which removes the top element of the stack, Find-Min, which returns (but does not remove) the smallest element of the stack Full Code package . . . Read more

Problem statement Given a matrix in which each row and each column is sorted, write a method to find an element in it. Solution Assumptions: 1. Rows are sorted left to right in ascending order. Columns are sorted top to bottom in ascending order. 2. Matrix is of size . . . . Read more

Problem Statement Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of representing n cents Solution This is a recursive problem, so let’s figure out how to do makeChange(n) using prior solutions (i . . . Read more