Leetcode 100 days series

Challenge of 100 days leet code.

#100daysLeetcode

LEETCODE SERIES || DAY 19 || (33) Search in Rotated Sorted Array

Day 19 Leet code series, today we will be picking the problem Search in Rotated Sorted Array (https://leetcode.com/problems/search-in-rotated-sorted-array/). There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], …, nums[n-1], nums[0], nums[1], …,…

LEETCODE SERIES || DAY 18 || (34) Find First and Last Position of Element in Sorted Array

Day 17 Leet code series, today we will be picking the problem Find First and Last Position of Element in Sorted Array (https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/). Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity.…

LEETCODE SERIES || DAY 16 || (155) Min Stack

Day 16 Leet code series, today we will be picking the problem Min Stack (https://leetcode.com/problems/min-stack/). Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes the stack object. void push(int val) pushes the element val onto the stack. void pop() removes the element on the top of the stack. int…

LEETCODE SERIES || DAY 15 || (104) Maximum Depth of Binary Tree

Day 15 Leet code series, today we will be picking the problem Maximum Depth of Binary Tree (https://leetcode.com/problems/maximum-depth-of-binary-tree/). Given the root of a binary tree, return its maximum depth. A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example 1: Input: root = [3,9,20,null,null,15,7] Output:…

LEETCODE SERIES || DAY 14 || (1561) Maximum Number of Coins You Can Get

Day 14 Leet code series, today we will be picking the problem Maximum Number of Coins You Can Get (https://leetcode.com/problems/maximum-number-of-coins-you-can-get/). There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows: In each step, you will choose any 3 piles of coins (not necessarily consecutive). Of your choice, Alice will pick…

LEETCODE SERIES || DAY 11 || (238) Product of Array Except Self

Day 11 Leet code series, today we will be picking the problem Product of Array Except Self (https://leetcode.com/problems/product-of-array-except-self/). Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without…

LEETCODE SERIES || DAY 10 || (152) Maximum Product Subarray

Day 10 Leet code series, today we will be picking the problem Maximum Product Subarray (https://leetcode.com/problems/maximum-product-subarray/). Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. A subarray is a contiguous subsequence of the…

LEETCODE SERIES || DAY 9 || (53) Maximum Subarray

Day 9 Leet code series, today we will be picking the problem Maximum Subarray (https://leetcode.com/problems/maximum-subarray/). Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum…

LEETCODE SERIES || DAY 4 || (15) 3sum

Day 4 Leet code series, today we will be picking the problem Three sum (https://leetcode.com/problems/3sum/). Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. Example 1: Input: nums…

LEETCODE SERIES || DAY 3 || (167)Two Sum II – Array is Sorted

Day 3 Leet code series, today we will be picking the problem two sum II – Array is Sorted (https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/). Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2 <= numbers.length. Return the indices of the two numbers, index1 and index2, added…

LEETCODE SERIES || DAY 2 || (136) Single Number

Day 2 Leet code series, today we will be picking the problem Single Number (https://leetcode.com/problems/single-number/). Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2]…

LEETCODE SERIES || DAY 1 || (121)Best Time To Buy And Sell Stocks

Day 1 Leet code series, today we will be picking the problem best time to buy and sell stocks (https://leetcode.com/problems/best-time-to-buy-and-sell-stock/). You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that…

Leave a comment