Leetcode 0268. Missing Number

Posted on Mon 09 December 2024 in Leetcode • Tagged with math

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

Difficulty: Easy

Premium: False

Question

Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.   Example 1:

Input: nums = [3,0,1] Output: 2 Explanation: n = 3 …


Continue reading

Leetcode 0621. Task Scheduler

Posted on Sun 08 December 2024 in Leetcode • Tagged with greedy, math

Question Link : https://leetcode.com/problems/task-scheduler/

Difficulty: Medium

Premium: False

Question

You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of one task. Tasks can be completed …


Continue reading

Leetcode 2955. Number of Same-End Substrings

Posted on Fri 22 November 2024 in Leetcode Premium • Tagged with math, binary-search, prefix-sum

Question Link : https://leetcode.com/problems/number-of-same-end-substrings/

Difficulty: Medium

Premium: True

Question

You are given a 0-indexed string s, and a 2D array of integers queries, where queries[i] = [li, ri] indicates a substring of s starting from the index li and ending at the index ri (both inclusive), i …


Continue reading

Leetcode 0009. Palindrome Number

Posted on Mon 27 March 2023 in Leetcode • Tagged with palindrome, math

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

Difficulty: Easy

Premium: False

Question

Given an integer x, return true if x is a palindrome, and false otherwise.   Example 1:

Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left.

Example 2:

Input …


Continue reading

Leetcode 2348. Number of Zero-Filled Subarrays

Posted on Mon 20 March 2023 in Leetcode • Tagged with array, math

Question Link : https://leetcode.com/problems/number-of-zero-filled-subarrays/

Difficulty: Medium

Premium: False

Question

Given an integer array nums, return the number of subarrays filled with 0. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1:

Input: nums = [1,3,0,0,2,0,0,4] Output …


Continue reading

Leetcode 0263. Ugly Number

Posted on Thu 17 November 2022 in Leetcode • Tagged with math

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

Difficulty: Easy

Question

An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return true if n is an ugly number.   Example 1:

Input: n = 6 Output: true Explanation: 6 = 2 × …


Continue reading

Leetcode 0223. Rectangle Area

Posted on Wed 16 November 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/rectangle-area/

Difficulty: Medium

Question

Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles. The first rectangle is defined by its bottom-left corner (ax1, ay1) and its top-right corner (ax2, ay2). The second rectangle …


Continue reading

Leetcode 2413. Smallest Even Multiple

Posted on Wed 09 November 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/smallest-even-multiple/

Difficulty: Easy

Question

Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.   Example 1:

Input: n = 5 Output: 10 Explanation: The smallest multiple of both 5 and 2 is 10.

Example 2:

Input …


Continue reading

Leetcode 2427. Number of Common Factors

Posted on Tue 08 November 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/number-of-common-factors/

Difficulty: Easy

Question

Given two positive integers a and b, return the number of common factors of a and b. An integer x is a common factor of a and b if x divides both a and b.   Example 1:

Input: a = 12 …


Continue reading

Leetcode 2455. Average Value of Even Numbers That Are Divisible by Three

Posted on Fri 04 November 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/

Difficulty: Easy

Question

Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3. Note that the average of n elements is the sum of the n elements divided by n and rounded …


Continue reading