## Sum of distinct elements among two given sets

Objective: Given two sets of elements, find the sum of all distinct elements from the set. In other words, find the sum of all elements which are present in either of the given set. ...

Skip to content# Category: Arrays

## Sum of distinct elements among two given sets

## Stable Marriage Problem – Gale–Shapley Algorithm – Java

## Given an array, find three-element sum closest to Zero

## Print sorted unique elements of a given array

## Given an array, print all unique subsets with a given sum.

## Sum of length of subsets which contains given value K and all elements in subsets are less than equal to K.

## Replace array elements with maximum element on the right.

## Unique Integers in array that sum up to zero.

## Print all middle elements of the given matrix/2D array.

## Find the number of distinct Islands OR connected components.

## Depth-First Search (DFS) in 2D Matrix/2D-Array – Recursive Solution

## Breadth-First Search (BFS) in 2D Matrix/2D-Array

## Number of Islands using BFS

## Print boundary of given matrix/2D array.

## Depth-First Search (DFS) in 2D Matrix/2D-Array – Iterative Solution

@tutorialhorizon

Objective: Given two sets of elements, find the sum of all distinct elements from the set. In other words, find the sum of all elements which are present in either of the given set. ...

Stable Marriage Given N men and N women and the marriage preference order for each man and woman. Their marriage will be stable when these men and women marry in such a manner so...

Objective: Given an array of integers, find the sum of any three elements which is closest to zero. The array may contain positive and negative elements. Example: Given Input: [-1, 4, -2, 5, 10,...

Objective: Given an array of integers with duplicates, write a program to print unique elements in the array in sorted order. Example: Given Input: [6, 1, 8, 5, 2, 10, 17, 25, 6, 5,...

Objective: Given an array of integers and number N, Write an algorithm to find and print all the subsets of the array for which sum is equal to N. Example: input [] = {6,2,7,8,2,4,1,3,7,5}...

Objective: Given an array of numbers and integer K. Your task is to find lengths of all the subsets which contain value K and all elements in the subset are less than equal to...

Objective: Given an array of integers, write a program to replace its elements with the maximum element on the right side from their respective positions. Note: If the element is equal to the maximum...

Objective: Given an integer N, write a function to return an array containing N unique integers that sum up to zero. There are many possible arrays that sum up to 0 for any N,...

Objective: Given a two-dimensional array, write a program to print all middle elements of the array. Or In other words, print all the elements from the array except boundary elements. Example: int [][] grid...

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

Objective: Given a two-dimensional array or matrix, Do the depth-First Search (DFS) to print the elements of the given matrix. Implement the Depth-first traversal in a recursive manner. Example: int [][] grid = new...

Objective: Given a two-dimensional array or matrix, Do the breadth-First Search (BFS) to print the elements of the given matrix. Implement a Breadth-first traversal in an iterative manner. Example: int [][] grid = new...

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...

Objective: Given a two-dimensional array, write a program to print the boundary of the array. Example: int [][] grid = new int[][] { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 8, 7,...

Objective: Given a two-dimensional array or matrix, Do the depth-First Search (DFS) to print the elements of the given matrix. Implement the Depth-first traversal in an iterative manner. Example: int [][] grid = new...

%d bloggers like this: