# Blogs Hub

### by AskGif | Oct 19, 2020 | Category :coding

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

### by AskGif | Oct 18, 2020 | Category :coding

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

### by AskGif | Oct 18, 2020 | Category :coding

#### 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 />

### by AskGif | Oct 18, 2020 | Category :coding

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

### by AskGif | Oct 18, 2020 | Category :coding

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

### by AskGif | Oct 18, 2020 | Category :coding

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

### by AskGif | Oct 17, 2020 | Category :coding

#### Relative Ranks - Array - Easy - LeetCode

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal". Example 1:<br />Input: [5, 4, 3, 2, 1]<br />Output: ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"]<

### by AskGif | Sep 27, 2020 | Category :coding

#### Sum of All Odd Length Subarrays - Array - Easy - LeetCode

Given an array of positive integers arr, calculate the sum of all possible odd-length subarrays. A subarray is a contiguous subsequence of the array. Return the sum of all odd-length subarrays of arr. &nbsp; Example 1: Input: arr = [1,4,2,5,3]<br />Output: 58<br

### by AskGif | Sep 27, 2020 | Category :coding

#### Special Positions in a Binary Matrix - Array - Easy - LeetCode

Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat. A position (i,j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed). &nbsp; Example 1:

### by AskGif | Sep 27, 2020 | Category :coding

#### Matrix Diagonal Sum - Array - Easy - LeetCode

Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal. Example 1: Input: mat = [[1,2,3],<br />&nbsp; &nbsp; &

### by AskGif | Sep 27, 2020 | Category :coding

#### Detect Pattern of Length M Repeated K or More Times - Array - Easy - LeetCode

Given an array of positive integers arr, &nbsp;find a pattern of length m that is repeated k or more times. A pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length