Blogs Hub

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

by AskGif | Oct 18, 2020 | Category :coding

Print in Order - Multi Threading - Easy - LeetCode

Print in Order - Multi Threading - Easy - LeetCode

Suppose we have a class: public class Foo {<br />&nbsp; public void first() { print("first"); }<br />&nbsp; public void second() { print("second"); }<br />&nbsp; public void third() { print("third"); }<br />}<br />The same instance of Foo will be passed to three different threads. Thread A

read more...

by AskGif | Oct 18, 2020 | Category :coding

Shortest Distance to a Character - Array - Easy - LeetCode

Shortest Distance to a Character - Array - Easy - LeetCode

Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. Example 1: Input: S = "loveleetcode", C = 'e'<br />Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]<br />&nbsp; Note: S string length is i

read more...

by AskGif | Oct 17, 2020 | Category :coding

Number of Lines To Write String - String - Easy - LeetCode

Number of Lines To Write String - String - Easy - LeetCode

We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units, it is written on the next line. We are given an array widths, an array where widths[0] is the width

read more...

by AskGif | Oct 17, 2020 | Category :coding

Rotate String - String - Easy - LeetCode

Rotate String - String - Easy - LeetCode

We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example, if A = 'abcde', then it will be 'bcdea' after one shift on A. Return True if and only if A can become B after some number of shifts on A.</p

read more...