## Number of Islands

Objective: Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. Assume...

@tutorialhorizon

Objective: Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. Assume...

Earlier we had discussed how to evaluate postfix expressions where operands are of single-digit. In this article, we will discuss how to evaluate postfix expressions for any number ( not necessarily single digit.) Postfix...

Problem Statement: When customers book an Airbnb the total price, which includes base price + service fee + cleaning fee. all these prices are in decimals. Write an algorithm to round each price such...

Objective: Given an array of integers, write an algorithm to find the third smallest element in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 10}; Output: Third smallest element...

Objective: Given a Stack, write an algorithm to reverse the stack. Example: Original Stack: [14, 9, 67, 91, 101, 25] Reversed Stack: [25, 101, 91, 67, 9, 14] Approach: Use Recursion In this solution,...

Objective: Given a stack of integers, write an algorithm to sort the stack using a temporary stack. Example: Given Stack: [14, 9, 67, 91, 101, 25] Sorted Stack: [9, 14, 25, 67, 91, 101]...

Objective: Given an array of strings, write an algorithm to group the anagrams. Example: Input: [rat, art, cat, act, dog, god, tar, pat] Output: [rat, art, tar] [cat, act] [pat] [dog, god] Approach: If...

Earlier we have seen linear search and binary search and how these work individually, In this article we will compare these two search algorithms. If you are new to these, please read the prerequisites...

Objective: Given an array of integers, write an algorithm to find the third largest element in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 1, 10} Output: Third largest...

Objective: Given an array of integers that contains duplicates as well. Write a program to find the sum of all unique elements in the array. This problem is also referred to as find the...

Objective– Given an array of numbers, write a java program to find the largest element in the given array. Example: int [] a = {1, 5, 3, 9, 2, 8, 2} Largest Element: 9...

Objective: Given an array of integers, write an algorithm to find the three smallest elements in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 10}; Output: 1, 2, 6...

Earlier we saw about Stack and its implementation using Linked List. Java has a built in class for Stack. In this article we will discuss about it in detail. First brief about Stack. What...

Objective: Given an array of integers, write a program to check if array contains all unique numbers. Example: Integer [] arrA = { 1, 2, 3, 6, 4, 9, 8}; Output: Array has all...

Objective: Given an array of integers which contains duplicates as well. Write a program to find the product of all unique elements in the array. This problem is also referred as find the product...

%d bloggers like this: