Leetcode 0202. Happy Number

Posted on Mon 18 November 2024 in Leetcode • Tagged with set, fast-slow-pointer

Question Link : https://leetcode.com/problems/happy-number/

Difficulty: Easy

Premium: False

Question

Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process:

Starting with any positive integer, replace the number by the sum of the squares of its …


Continue reading

Leetcode 0217. Contains Duplicate

Posted on Mon 18 November 2024 in Leetcode • Tagged with set

Question Link : https://leetcode.com/problems/contains-duplicate/

Difficulty: Easy

Premium: False

Question

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.   Example 1:

Input: nums = [1,2,3,1] Output: true Explanation: The element …


Continue reading

Leetcode 0771. Jewels and Stones

Posted on Mon 02 September 2024 in Leetcode • Tagged with set

Question Link : https://leetcode.com/problems/jewels-and-stones/

Difficulty: Easy

Premium: False

Question

You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the …


Continue reading