Coding Interviews

Leetcode 1502: Can Make Arithmetic Progression From Sequence

Category: Easy Problem Given an array of numbers arr. A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Return true if the array can be rearranged to form an arithmetic progression, otherwise, return false. https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/ Examples Example 1: Example 2: Constraints 2 <= arr.length <= 1000 -10^6 <= arr[i] <= […]

Leetcode 1502: Can Make Arithmetic Progression From Sequence Read More »

Leetcode 1207: Unique Number of Occurrences

Category: Easy Problem 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. https://leetcode.com/problems/unique-number-of-occurrences/ Examples: Example 1 Example 2 Example 3 Constraints: 1 <= arr.length <= 1000 -1000 <= arr[i] <= 1000 Solution Approach In this problem, we need to find if

Leetcode 1207: Unique Number of Occurrences Read More »

Leetcode 1614: Maximum Nesting Depth of the Parentheses

Category: Easy Problem A string is a valid parentheses string (denoted VPS) if it meets one of the following: It is an empty string “”, or a single character not equal to “(” or “)”, It can be written as AB (A concatenated with B), where A and B are VPS‘s, or It can be written as (A), where A is a VPS. We can similarly define the nesting depth depth(S) of any VPS S as follows: depth(“”) = 0

Leetcode 1614: Maximum Nesting Depth of the Parentheses Read More »

Leetcode 1295: Find Numbers with Even Number of Digits

Category : Easy Problem Given an array nums of integers, return how many of them contain an even number of digits. https://leetcode.com/problems/find-numbers-with-even-number-of-digits/ Examples Example 1: Example 2: Constraints 1 <= nums.length <= 500 1 <= nums[i] <= 10^5 Solution Approach The problem states that we need to find a count of all the numbers in the array which has

Leetcode 1295: Find Numbers with Even Number of Digits Read More »

Leetcode 1486: XOR Operation in an Array

Category : Easy Problem Given an integer n and an integer start. Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums. https://leetcode.com/problems/xor-operation-in-an-array/ Examples Example 1: Example 2: Example 3: Example 4: Constraints 1 <= n <= 1000 0 <= start <= 1000 n == nums.length Solution Approach In this problem, we

Leetcode 1486: XOR Operation in an Array Read More »

Subtract the Product and Sum of Digits of an Integer

Leetcode 1281: Subtract the Product and Sum of Digits of an Integer

Category : Easy Problem Given an integer number n, return the difference between the product of its digits and the sum of its digits. https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/ Examples Example 1: Example 2: Constraints 1 <= n <= 10^5 Solution Approach In this question, you just need to find the sum and product of the digits of a given

Leetcode 1281: Subtract the Product and Sum of Digits of an Integer Read More »

Leetcode 1528: Shuffle String

Category : Easy Problem Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string. https://leetcode.com/problems/shuffle-string/ Examples Example 1: Example 2: Example 3: Example 4: Example 5: Constraints s.length == indices.length == n 1 <= n <= 100 s contains only

Leetcode 1528: Shuffle String Read More »

Leetcode 1431: Kids With the Greatest Number of Candies

Category : Easy Problem Given the array candies and the integer  extraCandies, where  candies[i] represents the number of candies that the ith kid has. For each kid check if there is a way to distribute  extraCandies among the kids such that he or she can have the greatest number of candies among them. Notice that multiple kids can have the greatest number of candies. https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/ Examples Example 1:

Leetcode 1431: Kids With the Greatest Number of Candies Read More »