Coding Interviews

Leetcode 1365: How Many Numbers Are Smaller Than the Current Number

Category : Easy Problem Given the array nums for each  nums[i] find out how many numbers in the array are smaller than it. That is, for each  nums[i] you have to count the number of valid  j's such that  j != i and  nums[j] < nums[i]. Return the answer in an array. https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ Examples Example 1: Example 2: Example 3: Constraints: 2 <= nums.length <= 500 0 […]

Leetcode 1365: How Many Numbers Are Smaller Than the Current Number Read More »

Leetcode 1480: Running Sum of 1d Array

Category : Easy Problem 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. https://leetcode.com/problems/running-sum-of-1d-array Examples Example 1: Example 2: Example 3: Constraints 1 <= nums.length <= 1000 -10^6 <= nums[i] <= 10^6 Solution Approach In this question, you just need to find the running sum i.e the at any

Leetcode 1480: Running Sum of 1d Array Read More »

Leetcode 9: Palindrome Number

Category : Easy Problem Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Follow up: Could you solve it without converting the integer to a string? https://leetcode.com/problems/palindrome-number/ Examples Example 1: Example 2: Example 3: Example 4: Constraints -231 <= x <= 231 – 1 Solution Approach To check if the number is

Leetcode 9: Palindrome Number Read More »

Leetcode 1470: Shuffle the Array

Category : Easy Problem Given the array nums consisting of 2n elements in the form [x1,x2,…,xn,y1,y2,…,yn]. Return the array in the form [x1,y1,x2,y2,…,xn,yn]. https://leetcode.com/problems/shuffle-the-array/ Examples Example 1:

Example 2:

Example 3:

Constraints: 1 <= n <= 500 nums.length == 2n 1 <= nums[i] <= 10^3 Solution Approach The solution is pretty straight forward you just need to find

Leetcode 1470: Shuffle the Array Read More »

Leetcode 20

Leetcode 20: Valid Parenthesis

Category : Easy Problem Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. leetcode.com/problems/valid-parentheses/ Examples: Example 1

Example 2

Example 3

Example

Leetcode 20: Valid Parenthesis Read More »