Category: Software Engineer

0

String to Integer (AtoI – ASCII to Integer) – Recursive Solution

Objective: Write a recursive function to 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...

0

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

0

Longest contiguous character in a given String – O(N) Solution

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

0

String to Integer (AtoI – ASCII to Integer)

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

0

Longest substring with at most two unique characters

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

0

Convert Prefix to Infix Expression

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

0

Convert Infix to Prefix 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-...

0

Max Flow Problem – Ford-Fulkerson Algorithm

Objective: Given a directed graph that represents a flow network involving source(S) vertex and Sink (T) vertex.  Each edge in the graph has an individual capacity which is the maximum flow that edge allows....

0

Evaluation of Infix expressions

Infix notation is commonly used in arithmetic formula or statements, the operators are written in-between their operands. Let’s assume the below Operands are real numbers. Permitted operators: +,-, *, /, ^(exponentiation) Blanks are permitted...

0

Least Recently Used (LRU) Cache – Using LinkedHashSet and Deque | Set 2

Objective: Design and Implement a data structure Least Recently Used (LRU) Cache. Earlier we had seen Least Recently Used (LRU) Cache – Using HashMap and Doubly Linked List. In this article, we will see...

0

Merge K sorted Linked List – Using Priority Queue

Objective: Given, K sorted linked list, Write an algorithm to merge all the linked list into one linked list which will be also be sorted. Example: List 1: –>1–>5 List 2: –>4–>8 List 3:...

%d bloggers like this: