Category Leetcode Solutions

[Solved] Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i – j) <= k.

Leetcode solutions MLP Feature Image

Question Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i – j) <= k. Example 1: Input: nums = [1,2,3,1], k = 3 Output: true Example 2: Input: nums = [1,0,1,1], k…

[Solved] Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

Leetcode solutions MLP Feature Image

Question Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. You must solve it in O(n) time complexity. Example 1: Input: nums = [3,2,1,5,6,4], k = 2…

[Solved] 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 digits.

Leetcode solutions MLP Feature Image

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 digits. Repeat the process until…

[Solved] Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest id. Note that you are supposed to write a DELETE statement and not a SELECT one.

Leetcode solutions MLP Feature Image

Question SQL Schema Table: Person +————-+———+ | Column Name | Type | +————-+———+ | id | int | | email | varchar | +————-+———+ id is the primary key column for this table. Each row of this table contains an email.…