Skip to content
the poor coder

Home / Author

Poor Man

2,994 posts
2021

Leetcode - Defanging an IP Address Solution

Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". Example 1: Example 2: Constraints: The given address is a valid IPv4 address…

1 min read
2021

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: Example 2: Example 3: Constraints: 1 <= nums.length <= 1000 -10^6 <= nums[i]…

leetcode1 min read
2021

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…

leetcode1 min read
2021

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: Example 2: Example 3: Constraints: 1 <= nums.length <= 100 1 <= nums[i] <= 100…

leetcode1 min read
2021

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: Example 2: Example 3…

leetcode1 min read
2021

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…

leetcode1 min read
2021

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…

leetcode1 min read
2020

Hackerrank Pairs Solution

You will be given an array of integers and a target value. Determine the number of pairs of array elements that have a difference equal to a target value. For example, given an array of [1, 2, 3, 4] and a target value…

2020

Hackerrank Minimum Loss Solution

Lauren has a chart of distinct projected prices for a house over the next several years. She must buy the house in one year and sell it in another, and she must do so at a loss. She wants to minimize her financial loss…

ESC