## Grouping of Anagrams

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

@tutorialhorizon

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

Problem Statement: There is an application that has several processes running in parallel and each process prints the logs in a single log file. Log message contains the process name, timestamp, message type (WARN,...

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 a binary tree, write an algorithm to count all the nodes in the tree. Example: Approach: Do postorder traversal. If the root is null return 0. (base case all well for the...

Objective: Given a number N, Write a program to find all prime numbers which are between 0 and N using Sieve of Eratosthenes algorithm. Prime Number: A prime number is a natural number that...

Objective: Given an input string, write an algorithm to find the longest contiguous character or in other words, find a maximum consecutive character in the string. Example: Input: “aaabbccccddbbaaa” Output: c, count = 4...

Objective: Given a Postfix expression, write an algorithm to convert it into Infix expression. Example: Input: Postfix expression: A B + Output: Infix expression- (A + B) Input: Postfix expression: ABC/-AK/L-* Output: Infix expression:...

The Collatz conjecture is a conjecture in mathematics which states that no matter what value of Positive Number N, If the below sequence is followed then, the sequence will always reach 1. If N...

Objective: Implement atoi, which converts string to an integer. Rules for converting string to an integer. If the string is null or empty, Integer will be 0. The first character of string may represent...

Objective: Given a number N, Write a program to find all prime numbers which are between 0 and N. Prime Number : A prime number is a natural number that has exactly two distinct...

Objective: Given a string, write an algorithm to find the longest substring with at most two characters. Example: Input: aabbccddc Output: ccddc, length: 5 Input: aabacbeeeebeaabb Output: beeeebe, length 7 Input: aaaaaa Output: Only...

Objective: Given a number N, find the largest number which is less than equal to N and has monotone increasing digits. Monotone Increasing Digits – If all the pairs (x, y) of adjacent digits...

Objective: Given a Prefix expression, write an algorithm to convert it into Infix expression. Example: Input: Prefix expression: + A B Output: Infix expression- (A + B) Input: Prefix expression: *-A/BC-/AKL Output: Infix expression:...

Objective: Given an Infix expression, write an algorithm to convert it into Prefix expression. Example: Input: Infix expression – A + B Output: Prefix expression- +AB Input: Infix expression – A+B*(C^D-E) Output: Prefix expression-...

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

%d bloggers like this: