Challenge of 100 days leet code.
#100daysLeetcode
LEETCODE SERIES || DAY 20 || (322) Coin Change
Day 20 Leet code series, today we will be picking the problem Coin Change (https://leetcode.com/problems/coin-change/). You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up…
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 17 || (141) Linked List Cycle
Day 17 Leet code series, today we will be picking the problem Linked List Cycle (https://leetcode.com/problems/linked-list-cycle/). Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by…
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(b) || (94) Binary Tree Inorder Traversal
Day 14 Leet code series, today we will be picking the problem Binary Tree Inorder Traversal (https://leetcode.com/problems/binary-tree-inorder-traversal/). Given the root of a binary tree, return the inorder traversal of its nodes’ values. Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Example 2: Input: root = [] Output: [] Example 3: Input: root = [1] Output: [1]
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 13 || (169) Majority Element
Day 13 Leet code series, today we will be picking the problem Majority Element (https://leetcode.com/problems/majority-element/). Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Example…
LEETCODE SERIES || DAY 12 || (75) Sort Colors
Day 12 Leet code series, today we will be picking the problem sort colors (https://leetcode.com/problems/sort-colors/). Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers 0, 1, and 2 to represent the color red, white, and…
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 8 || (55) Jump game
Day 8 Leet code series, today we will be picking the problem Jump game (https://leetcode.com/problems/jump-game/). You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. Example 1: Input: nums…
LEETCODE SERIES || DAY 7 || (35) Search Insert Position
Day 5 Leet code series, today we will be picking the problem Search Insert Position (https://leetcode.com/problems/search-insert-position/). Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log…
LEETCODE SERIES || DAY 6 || (338) Counting bits
Day 6 Leet code series, today we will be picking the problem Counting bits (https://leetcode.com/problems/counting-bits/). Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1’s in the binary representation of i. Example 1: Input: n = 2 Output: [0,1,1] Explanation: 0 –> 0 1 –> 1 2 –> 10 Example…
LEETCODE SERIES || DAY 5 || (70) Climbing stairs
Day 5 Leet code series, today we will be picking the problem Climbing Stairs (https://leetcode.com/problems/climbing-stairs/). You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation: There are two…
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