The encode function will encode a list of strings to a single string while the decode function will take the encoded string and return the original list of strings as output

Encoding and Decoding Functions for Strings

Problem Statement We have to implement an encode function that takes a list of string values as input and returns a single encoded string that could be transmitted over a network. On the other side of the network, the decode function will take the encoded string as input and return the original list of string values as output. A delimiter could be used to differentiate between words. For example, ["Hello", "World"] could be encoded with comma delimiter (,) to "Hello,World"....

November 6, 2023 · 6 min · Avnish
The groupAnagrams function will return an array with anagrams grouped together

Group Anagrams in an Array

Problem Statement We have to implement a groupAnagram function that takes an array of strings as input and returns a new array with anagrams grouped. The input string array is assumed to be composed entirely of lowercase English characters. Brute Force Solution If two strings are anagrams then their sorted order will be the same. Thus, anagrams could be grouped under their sorted order. The brute-force implementation of groupAnagram uses a hashmap for grouping....

October 22, 2023 · 7 min · Avnish
The isAnagram function will return true if both input strings are anagram and false otherwise

Identify Anagrams

Problem Statement We have to implement an isAnagram() function that takes two strings as input and returns true if they both are anagrams and false otherwise. Multiple words could be anagrams of each other if they contain the same characters with the same frequency of occurrence. For word counter: trounce is an anagram. trouncee isn’t an anagram, because the character e appears twice in trouncee. tounce isn’t an anagram, because the character r is missing....

October 12, 2023 · 5 min · Avnish
Rabin-Karp Substring Search

Rabin-Karp Substring Search

Searching contents on a website for a specific keyword, code search in text editors & IDEs, and information retrieval systems used in libraries and archives are use cases for an algorithm that searches a string within another string. Unlike searching for a single character, searching for a complete string could be challenging. If we search string ION in DICTIONARY. For each character in DICTIONARY, we have to look for I, O, and N in the same order....

October 8, 2023 · 8 min · Avnish
Arrays, Strings, and HashMaps

Arrays, Strings, and HashMaps

Data structures like arrays, strings, and hashmaps are available by default in most programming languages. They facilitate storage of large amounts of data in an efficient format which makes it easier (and sometimes relatively faster) to access during runtime. Arrays An array is a sequential store of data (referred to as elements). In languages like Python, an array can store elements with multiple data types, like, [1, "Hello, World", True] but for languages like Go, C++, and Java an array can store elements of a singular data type....

September 29, 2023 · 8 min · Avnish