Blogs Hub

by AskGif | Oct 24, 2020 | Category :coding

Search in Rotated Sorted Array - Array - Medium - LeetCode

Search in Rotated Sorted Array - Array - Medium - LeetCode

You are given an integer array nums sorted in ascending order, and an integer target. Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). If target is found in the array return its index, otherwise, return -1.</p

read more...

by AskGif | Oct 24, 2020 | Category :coding

Next Permutation - Array - Medium - LeetCode

Next Permutation - Array - Medium - LeetCode

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order). The replacement must be in place and use

read more...

by AskGif | Oct 24, 2020 | Category :coding

4Sum - Array - Medium - LeetCode

4Sum - Array - Medium - LeetCode

Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Notice that the solution set must not contain duplicate quadruplets. &nbsp;</p

read more...

by AskGif | Oct 23, 2020 | Category :coding

3Sum Closest - Array - Medium - LeetCode

3Sum Closest - Array - Medium - LeetCode

Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. &nbsp; Example 1: Input: nums = [-1,2,1,-4], targ

read more...

by AskGif | Oct 19, 2020 | Category :coding

3Sum - Array - Medium - LeetCode

3Sum - Array - Medium - LeetCode

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Notice that the solution set must not contain duplicate triplets. &nbsp; Example 1: Input: nums = [-1,0,1,2

read more...

by AskGif | Oct 18, 2020 | Category :coding

Container With Most Water - Array - Medium - LeetCode

Container With Most Water - Array - Medium - LeetCode

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the m

read more...

by AskGif | Oct 18, 2020 | Category :coding

Largest Substring Between Two Equal Characters - Array - Easy - LeetCode

Largest Substring Between Two Equal Characters - Array - Easy - LeetCode

Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1. A substring is a contiguous sequence of characters within a string. &nbsp; Example 1: Input: s = "aa"<br />

read more...

by AskGif | Oct 18, 2020 | Category :coding

Mean of Array After Removing Some Elements - Array - Easy - LeetCode

Mean of Array After Removing Some Elements - Array - Easy - LeetCode

1619. Mean of Array After Removing Some Elements<br />Easy 30 5 Add to List Share<br />Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements. Answers within 10-5 of the actual answ

read more...

by AskGif | Oct 18, 2020 | Category :coding

Maximum Nesting Depth of the Parentheses - Stack - Easy - LeetCode

Maximum Nesting Depth of the Parentheses - Stack - Easy - LeetCode

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 ")",<br />It can be written as AB (A concatenated with B), where A and B are VPS's, or<br />It can be written as (A), where A is a VPS.

read more...

by AskGif | Oct 18, 2020 | Category :coding

Special Array With X Elements Greater Than or Equal X - Array - Easy - LeetCode

Special Array With X Elements Greater Than or Equal X - Array - Easy - LeetCode

You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x. Notice that x does not have to be an element in nums. Return x if the array is special, othe

read more...

by AskGif | Oct 18, 2020 | Category :coding

Number of Days Between Two Dates - Maths - Easy - LeetCode

Number of Days Between Two Dates - Maths - Easy - LeetCode

Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. &nbsp; Example 1: Input: date1 = "2019-06-29", date2 = "2019-06-30"<br />Output: 1<br />Example 2: Input: date

read more...

by AskGif | Oct 18, 2020 | Category :coding

Reformat Department Table - Sql - Easy - LeetCode

Reformat Department Table - Sql - Easy - LeetCode

Table: Department +---------------+---------+<br />| Column Name &nbsp; | Type &nbsp; &nbsp;|<br />+---------------+---------+<br />| id &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| int &nbsp; &nbsp; |<br />| revenue &nbsp; &nbsp; &nbsp; | int &nbsp; &nbsp; |<br />| month &nbsp; &nbsp; &nbsp

read more...