Blogs Hub

by Sumit Chourasia | Mar 31, 2021

Check if Array Is Sorted and Rotated - Array - Easy - LeetCode - MiniTV

Check if Array Is Sorted and Rotated - Array - Easy - LeetCode - मिनी टीवी

Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false. There may be duplicates in the original array. Note: An array A rotated by x positions results in an array B

read more...

by Sumit Chourasia | Mar 04, 2021

Maximum Swap - Array - Medium - LeetCode - MiniTV

Maximum Swap - Array - Medium - LeetCode - मिनी टीवी

Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get. Example 1:<br />Input: 2736<br />Output: 7236<br />Explanation: Swap the number 2 and the number 7.<br />Example 2:<br />Input: 9973<br />O

read more...

by Sumit Chourasia | Feb 13, 2021

Sum of Unique Elements - Array - Easy - LeetCode - MiniTV

Sum of Unique Elements - Array - Easy - LeetCode - मिनी टीवी

You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. Return the sum of all the unique elements of nums. &nbsp; Example 1: Input: nums = [1,2,3,2]<br />Output: 4<br />Explanation: The unique element

read more...

by Sumit Chourasia | Jan 26, 2021

Find the Highest Altitude - Array - Easy - LeetCode - MiniTV

Find the Highest Altitude - Array - Easy - LeetCode - मिनी टीवी

There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integer array gain of length n where gain[i] is the net gain in altitude between points i​​​​​​ and i + 1 for a

read more...

by Sumit Chourasia | Jan 18, 2021

Number Of Rectangles That Can Form The Largest Square - Array - Easy - LeetCode - MiniTV

Number Of Rectangles That Can Form The Largest Square - Array - Easy - LeetCode - मिनी टीवी

You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi. You can cut the ith rectangle to form a square with a side length of k if both k &lt;= li and k &lt;= wi. For example, if you have a rectangle [4,6], you can cut it to g

read more...

by Sumit Chourasia | Jan 10, 2021

Decode XORed Array - Array - Easy - LeetCode - MiniTV

Decode XORed Array - Array - Easy - LeetCode - मिनी टीवी

There is a hidden integer array arr that consists of n non-negative integers. It was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3]. You are given the encoded array. Yo

read more...

by Sumit Chourasia | Jan 09, 2021

Task Scheduler - Array - Medium - LeetCode - MiniTV

Task Scheduler - Array - Medium - LeetCode - मिनी टीवी

Given a characters array tasks, representing the tasks a CPU needs to do, where each letter represents a different task. Tasks could be done in any order. Each task is done in one unit of time. For each unit of time, the CPU could complete either one task or just be idle. However, there is

read more...

by Sumit Chourasia | Jan 08, 2021

Maximum Units on a Truck - Array - Easy - LeetCode - MiniTV

Maximum Units on a Truck - Array - Easy - LeetCode - मिनी टीवी

You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]: numberOfBoxesi is the number of boxes of type i.<br />numberOfUnitsPerBoxi is the number of units in each box of the type i.<br />You

read more...

by Sumit Chourasia | Dec 02, 2020

Richest Customer Wealth - String - Easy - LeetCode - MiniTV

Richest Customer Wealth - String - Easy - LeetCode - मिनी टीवी

You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has. A customer's wealth is the amount of money they have in all their bank accounts. The

read more...

by Sumit Chourasia | Nov 21, 2020

Valid Triangle Number - Array - Medium - LeetCode - MiniTV

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

read more...

by Sumit Chourasia | Nov 21, 2020

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

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

read more...

by Sumit Chourasia | Nov 21, 2020

Array Nesting - Array - Medium - LeetCode - MiniTV

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

read more...