You've successfully subscribed to The Poor Coder | Hackerrank Solutions
Great! Next, complete checkout for full access to The Poor Coder | Hackerrank Solutions
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.

leetcode

Beeze Aal

Leetcode - Reformat The String Solution

Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same
Beeze Aal

Leetcode - Reverse Vowels of a String Solution

Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle"Example 2: Input: "leetcode" Output: "leotcede"Note: The vowels does not include the letter "y". Solution in pythonclass Solution: def reverseVowels(self, s: str) -> str:
Beeze Aal

Leetcode - Richest Customer Wealth Solution

You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has. A customer's wealth is the amount of money they have in all their
Beeze Aal

Leetcode - Running Sum of 1d Array Solution

Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+
Beeze Aal

Leetcode - Kids With the Greatest Number of Candies Solution

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.
Beeze Aal

Leetcode - N-Repeated Element in Size 2N Array Solution

In a 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. Example 1: Input: [1,2,3,3] Output: 3Example 2: Input: [2,1,2,5,3,2] Output: 2Example 3: Input:
Beeze Aal

Leetcode - Shuffle String Solution

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. Example 1: Input: s = "codeleet", indices = [4,5,6,7,0,
Beeze Aal

Leetcode - Number of Good Pairs Solution

Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i < j. Return the number of good pairs. Example 1: Input: nums = [1,2,3,1,1,3] Output: 4 Explanation: There are 4 good pairs (0,3), (0,4)
Beeze Aal

Leetcode - Find Numbers with Even Number of Digits Solution

Given an array nums of integers, return how many of them contain an even number of digits. Example 1: Input: nums = [12,345,2,6,7896] Output: 2 Explanation: 12 contains 2 digits (even number of digits). 345 contains 3 digits (odd number of digits). 2 contains 1 digit (odd
Beeze Aal

Leetcode - Palindrome Number Solution

Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not. Example 1: Input: x = 121 Output: trueExample 2: Input: x = -121 Output: false Explanation: From left to
Beeze Aal

Leetcode - Reverse Integer Solution

Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1: Input:
Beeze Aal

Leetcode - Two Sum - Solution

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any