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