Hash Tables: Ransom Note

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

View Solution →

Two Strings

Given two strings, determine if they share a common substring . A substring may be as small as one character. For example, the words "a", "and", "art" share the common substring a. The words "be" a

View Solution →

Sherlock and Anagrams

Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams o

View Solution →

Count Triplets

You are given an array and you need to find number of tripets of indices (i, j, k) such that the elements at those indices are in geometric progression for a given common ratio r and i < j < k . F

View Solution →

Frequency Queries

You are given q queries. Each query is of the form two integers described below: - 1 x: Insert x in your data structure. - 2 y: Delete one occurence of y from your data structure, if present. - 3 z

View Solution →

Sorting: Bubble Sort

Consider the following version of Bubble Sort: for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { // Swap adjacent elements if they are in decreasing order

View Solution →

Sorting: Comparator

Comparators are used to compare two objects. In this challenge, you'll create a comparator and use it to sort an array. The Player class is provided in the editor below. It has two fields: 1. name

View Solution →