Leetcode 0953. Verifying an Alien Dictionary

Posted on Fri 06 December 2024 in Leetcode • Tagged with hash-map, topological-sorting

Question Link : https://leetcode.com/problems/verifying-an-alien-dictionary/

Difficulty: Easy

Premium: False

Question

In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters. Given a sequence of words written in the alien language …


Continue reading

Leetcode 0380. Insert Delete GetRandom O(1)

Posted on Mon 28 November 2022 in Leetcode • Tagged with hash-map, array

Question Link : https://leetcode.com/problems/insert-delete-getrandom-o1/

Difficulty: Medium

Premium: False

Question

Implement the RandomizedSet class:

RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. bool remove(int val) Removes …


Continue reading

Leetcode 0001. Two Sum

Posted on Wed 23 November 2022 in Leetcode • Tagged with hash-map

Question Link : https://leetcode.com/problems/two-sum/

Difficulty: Easy

Premium: False

Question

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 …


Continue reading

Leetcode 2418. Sort the People

Posted on Fri 11 November 2022 in Leetcode • Tagged with hash-map

Question Link : https://leetcode.com/problems/sort-the-people/

Difficulty: Easy

Question

You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index i, names[i] and heights[i] denote the name and height of the …


Continue reading

Leetcode 0049. Group Anagrams

Posted on Thu 27 October 2022 in Leetcode • Tagged with hash-map, anagram

Question Link : https://leetcode.com/problems/group-anagrams/

Difficulty: Medium

Question

Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the …


Continue reading

Leetcode 0347. Top K Frequent Elements

Posted on Sat 09 April 2022 in Leetcode • Tagged with k-most-points, bucket-sort, hash-map

Question Link : https://leetcode.com/problems/top-k-frequent-elements/

Difficulty: Medium

Question

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.   Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2 …


Continue reading