Maximum Sum Subarray of Size K

Let’s discuss a interesting problem maximum sum subarray of size k

Given an array of positive integers and a positive number K. Write a code to find the maximum sum subarray of size k.

For example:

Let’s first understand what all subarrays we can form whose size is 3.

i) First subarray is {2, 1, 5} and it’s sum is 8.

ii) Second subarray is {1, 5, 1} and it’s sum is 7.

iii) Third subarray is {5, 1,3} and it’s sum is 9.

iv) Fourth subarray is {1, 3, 2} and it’s sum is 6.

Out of all these subarrays of size three, the maximum sum subarray is {5, 1, 3} and it’s sum is 9.

Group Anagrams Together

Given an array of strings or a list of words, write a code to group anagrams together.

what are Anagrams?

Two strings are said to be anagrams of each other if it contains the same characters, only the order of character in both the strings is different.

Check whether two strings are anagrams of each other or not

For example, Word “car” and “rac” are anagrams of each other. As both, the strings contain the same number of characters only the order of character is different in both the strings.

Now, let’s understand this problem statement with example.

For example:

Input: {“eat”, “tea”, “tan”, “ate”, “nat”, “bat”}

Output:

Remove Duplicates from a Sorted Linked List

In this tutorial, I am going to discuss a programming question to remove duplicates from a sorted linked list.

Given a sorted linked list, write a code to remove all duplicates such that each element appears only once.

For example:

Input:

1 -> 2 -> 2 -> 3 -> 3 -> NULL

Output:

1 -> 2 -> 3 -> NULL