The containsDuplicate function takes an array as input and returns true or false depending on the fact that array contains duplicate elements or not

Checking an Array for Duplicate Values

Problem Statement We have to implement a function containsDuplicate() that takes an integer array as input and returns true if an element occurs more than once and false otherwise. Brute Force Solution The simplest solution for this problem would be two nested loops, where the first loop will select an element and the second loop will select another element from the array and compare them. On the first occurrence of a duplicate element, the function will exit while returning true....

October 10, 2023 · 3 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
Time Complexity Comparison of Algorithms

Time Complexity

While programming allows us to create virtually anything, the true test of performance arises when we deploy the same code on a significantly larger scale. Time Complexity ($T(n)$) is a function that estimates the execution time of an algorithm given the amount of data to be processed as its input. It is a common benchmark used to measure an algorithm’s performance. Bounds of Time Complexity The output of the time complexity function will be a close estimate of an algorithm’s runtime yet it does not consider other characteristics of the data that could affect runtime....

September 22, 2023 · 8 min · Avnish

REST API Requests in Go

What is REST? REST (REpresentational State Transfer) is an architectural style for designing and developing APIs that could be used for client and server interactions. REST defines 6 architectural constraints for APIs: Uniform interface: API requests for a resource should look the same irrespective of its origin client. The Uniform Resource Identifier (URI) allocated to resources should be unique. Client-server: Changes on the client side should not affect the server and vice-versa....

September 15, 2023 · 6 min · Avnish