Leetcode Challenge

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.

S No. Date Problem Statement Solution Link Solution Approach Category Subcategory
1 23-10-2023 217. Contains Duplicate
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Solution Link 1 Just sort out the entire list and in one traverse you can see if the previous element matches. If you ran out of size then it means the entire list doesn't contain any duplicates Array Traversing
2 23-10-2023 242. Valid Anagram
Given two strings s and t, return true if t is an anagram of s, and false otherwise.An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Solution Link 1 So my go to solution for this. The first check if two string length is of different length then there is no chance it would be anagram. After this we will put two hash list and for each element check if the existing element is already there in opposite hash list and then remove it else add it to there hash list. At the end if both the hash list are empty at the end then return true else false String Anagram, Hash
3 23-10-2023 1. Two Sum
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer in any order.
Solution Link 1 So the simple approach that comes to me is to use hash table and for each item minus the target and map it as key and index as value and for each item check if the value is there in keys and return the index Array HashTable