Blogs Hub

by Sumit Chourasia | Oct 24, 2020 | Category :coding

Two Strings - HashMap - Easy - HackerRank

Two Strings - HashMap - Easy - HackerRank

Given two strings, determine if they share a common substring. A substring may be as small as one character. For example, the words "a", "and", "art" share the common substring . The words "be" and "cat" do not share a substring. Function Description Complete the function two

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Unique Number of Occurrences - Hash Table - Easy - LeetCode

Unique Number of Occurrences - Hash Table - Easy - LeetCode

Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. Example 1: Input: arr = [1,2,2,1,1,3]<br />Output: true<br />Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two valu

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Occurrences After Bigram - Hash Table - Easy - LeetCode

Occurrences After Bigram - Hash Table - Easy - LeetCode

Given words first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second. For each such occurrence, add "third" to the answer, and return the answer. &nbsp; Example 1

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Powerful Integers - Hash Table - Easy - LeetCode

Powerful Integers - Hash Table - Easy - LeetCode

Given two positive integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i &gt;= 0 and j &gt;= 0. Return a list of all powerful integers that have value less than or equal to bound. You may return the answer in any order. &nbsp;In your answer, each v

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

N-Repeated Element in Size 2N Array - Hash Table - Easy - LeetCode

N-Repeated Element in Size 2N Array - Hash Table - Easy - LeetCode

In an array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. Return the element repeated N times. &nbsp; Example 1: Input: [1,2,3,3]<br />Output: 3<br />Example 2: Input: [2,1,2,5,3,2]<br />Output: 2<br />Exampl

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Verifying an Alien Dictionary - Hash Table - Easy - LeetCode

Verifying an Alien Dictionary - Hash Table - Easy - LeetCode

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, and the order of the alphabet, return true if and only

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Uncommon Words from Two Sentences - Hash Table - Easy - LeetCode

Uncommon Words from Two Sentences - Hash Table - Easy - LeetCode

We are given two sentences A and B. &nbsp;(A sentence is a string of space separated words. &nbsp;Each word consists only of lowercase letters.) A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence. Return a list of all unc

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Subdomain Visit Count - Hash Table - Easy - LeetCode

Subdomain Visit Count - Hash Table - Easy - LeetCode

A website domain like "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com", and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leet

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Jewels and Stones - Hash Table - Easy - LeetCode

Jewels and Stones - Hash Table - Easy - LeetCode

You're given strings J representing the types of stones that are jewels, and S representing the stones you have. &nbsp;Each character in S is a type of stone you have. &nbsp;You want to know how many of the stones you have are also jewels. The letters in J are guaranteed distinct, and all

read more...

by Sumit Chourasia | Sep 30, 2020 | Category :coding

Shortest Completing Word

Shortest Completing Word

Given a string licensePlate and an array of strings words, find the shortest completing word in words. A completing word is a word that contains all the letters in licensePlate. Ignore numbers and spaces in licensePlate, and treat letters as case insensitive. If a letter appears more than

read more...

by Sumit Chourasia | Sep 29, 2020 | Category :coding

Longest Word in Dictionary - Hash Table - Easy - LeetCode

Longest Word in Dictionary - Hash Table - Easy - LeetCode

Given a list of strings words representing an English Dictionary, find the longest word in words that can be built one character at a time by other words in words. If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no ans

read more...

by Sumit Chourasia | Sep 29, 2020 | Category :coding

Design HashMap - Hash Table - Easy - LeetCode

Design HashMap - Hash Table - Easy - LeetCode

Design a HashMap without using any built-in hash table libraries. To be specific, your design should include these functions: put(key, value) : Insert a (key, value) pair into the HashMap. If the value already exists in the HashMap, update the value.<br />get(key): Returns the value

read more...