# Blogs Hub

### by Sumit Chourasia | Nov 21, 2020 | Category :coding

#### Valid Triangle Number - Array - Medium - LeetCode

Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.<br />Example 1:<br />Input: [2,2,3,4]<br />Output: 3<br />Explanation:<br />Valid combinations are:&nbsp;<br

### by Sumit Chourasia | Nov 21, 2020 | Category :coding

#### Shortest Unsorted Continuous Subarray - Array - Medium - LeetCode

Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order. Return the shortest such subarray and output its length. &nbsp; Example 1: Input: nums

### by Sumit Chourasia | Nov 21, 2020 | Category :coding

#### Array Nesting - Array - Medium - LeetCode

A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below. Suppose the first element in S starts with the selection of element A[i] of index = i, the next e

### by Sumit Chourasia | Nov 21, 2020 | Category :coding

#### Subarray Sum Equals K - Array - Medium - LeetCode

Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. &nbsp; Example 1: Input: nums = [1,1,1], k = 2<br />Output: 2<br />Example 2: Input: nums = [1,2,3], k = 3<br />Output: 2<br />&nbsp; Constra

### by Sumit Chourasia | Nov 20, 2020 | Category :coding

#### K-diff Pairs in an Array - Array - Medium - LeetCode

Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true: 0 &lt;= i, j &lt; nums.length<br />i != j<br />|nums[i] - nums[j]| == k<br />Notice that |val|

### by Sumit Chourasia | Nov 20, 2020 | Category :coding

#### Teemo Attacking - Array - Medium - LeetCode

In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning time duration per Teemo's attacking, you need to output the total time that Ashe is in poisoned cond

### by Sumit Chourasia | Nov 19, 2020 | Category :coding

#### Circular Array Loop - Array - Medium - LeetCode

You are given a circular array nums of positive and negative integers. If a number k at an index is positive, then move forward k steps. Conversely, if it's negative (-k), move backward k steps. Since the array is circular, you may assume that the last element's next element is the first element,

### by Sumit Chourasia | Nov 19, 2020 | Category :coding

#### Find All Duplicates in an Array - Array - Medium - LeetCode

Given an array of integers, 1 &le; a[i] &le; n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. Could you do it without extra space and in O(n) runtime? Example:<br />Input:<br />[4,3,2,7,8,2,3,1]</

### by Sumit Chourasia | Nov 19, 2020 | Category :coding

#### Insert Delete GetRandom O(1) - Array - Medium - LeetCode

Implement the RandomizedSet class: bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise.<br />bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise.<

### by Sumit Chourasia | Nov 19, 2020 | Category :coding

#### Game of Life - Array - Medium - LeetCode

According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." Given a board with m by n cells, each cell has an initial state live (1) or dead (0). Each cell interacts with its e

### by Sumit Chourasia | Nov 18, 2020 | Category :coding

#### Find the Duplicate Number - Array - Medium - LeetCode

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one duplicate number in nums, return this duplicate number. Follow-ups: How can we prove that at least one duplicate number must exist in nums?&nbsp;<b