In this problem, we’ll be performing some basic set operations on the given arrays like Union, Intersection, and Difference. I found this problem when I was writing a practice test on ADT (Array as a Data Structure). Examples Set Operations Union ∪ A union of two sets will contain the… Read More »Perform Set Operations on Arrays
Algorithms, Data Structures, Competitive Coding, and problems from LeetCode with complete Solution Approach, Pseudocode, and Explanation.
Remove duplicates from a sorted linked list. In this problem, as the list is already sorted, the duplicates are next to one another and easy to identify. However, as we are dealing with a linked list we need to connect the nodes carefully. Example Input Output, after removing duplicates Solution… Read More »Remove Duplicates from a Sorted Linked List
In the given problem, we have a sorted array, and we need to count the duplicates of each element. In simple words, we should print the no.of times each element occurs. Example Solution approach Since we have a sorted array, things become much easier. Once we traverse through an element,… Read More »Count the Duplicates of Array O(N)
Given, two strings and we need to check if those strings form an anagram. If you are wondering what’s an Anagram? When the characters of one word are obtained from rearranging the letters/characters of another word, they are called anagrams. Example Note: Important!, Anagrams can be a single word or… Read More »Anagram in Strings
Given, a sorted array of elements and we need to find all the pairs of elements that add up equally to a given target sum number, this can be done usually done using two loops, like a brute force method where all the elements are compared with every other element… Read More »Target Sum – Single Iteration O(N)
The Binary Search Algorithm, a simple and faster search. But on one condition, we need a sorted array or sort the given array before we perform a binary search. Why Binary Search? We can use linear search for smaller numbers but, when having hundreds, and thousands, to compare, it would… Read More »Binary Search Algorithm