My code collection of 100 Days Of Coding Challenge!
-
Rangoli Generative Art :
JavaScript project created on the auspicious day of Diwali festival โจ, to celebrate Rangoli ๐ธ in a Digital manner using Generative Art. -
Tic Tac Toe :
A fun little game created in JavaScript ๐ฅ with an elegant modern design! ๐ธ -
Jump Game LeetCode : ๐ธ
We 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 we can reach the last index, or false otherwise. -
Maximum Bags With Full Capacity of Rocks LeetCode : ๐ฐ
We are given two arrays capacity and rocks. The ith bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. We are also given an integer additionalRocks, we can place it in any of the bags. Return the maximum number of bags that could have full capacity after placing the additional rocks in some bags. -
Remove Stones to Minimize the Total LeetCode : ๐ช
We are given an array piles, where piles[i] is number of stones in ith pile, and an integer k. Choose any piles[i] and remove floor(piles[i] / 2) stones from it. We should apply this operation exactly k times and return the minimum possible total number of stones. -
Regular Expression Matching LeetCode : ๐!=๐ญ
Given an input string s and a pattern p, implement regular expression matching with'.'
for any single character and'*'
for zero or more of the preceding element. The matching should cover the entire input string (not partial) and return true or false. -
Design Circular Queue LeetCode : โป๏ธ
Design circular queue, it is a linear data structure, which follows FIFO (First In First Out) principle, and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer". By using circular queue, we can utlize empty spaces in front of the queue. -
Word Pattern LeetCode : ๐งฉ
Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. -
Detect Capital LeetCode : ๐
We define the usage of capitals in a word to be right when one of the case is followed: all letters capital, all letters not capital or only first letter capital. Given a stringword
, returntrue
if the usage of capitals is right. -
Container With Most Water LeetCode : ๐ง
Given an arrayheight
of lengthn
. There are n vertical lines drawn such that the two endpoints of thei
th
line are(i, 0)
and(i, height[i])
. Find two lines that together with the x-axis form a container, such that it contains the most water. Return the maximum amount of water a container can store. -
Delete Columns to Make Sorted LeetCode : ๐๏ธ
Given an array ofn
stringsstrs
, all of the same length. The strings could form a grid. For example,strs=["abc", "bce", "cae"]
. We want to delete the columns that are not sorted lexicographically and return the number of columns. -
Minimum Rounds to Complete All Tasks LeetCode : ๐โ
Given an arraytasks
, wheretasks[i]
represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level. Return the minimum rounds required to complete all the tasks, or-1
if it is not possible to complete all the tasks. -
Largest Number LeetCode : ๐ฏ
Given a list of non-negative integersnums
, arrange them such that they form the largest number and return it. Since the result may be very large, so we need to return a string instead of an integer. -
Minimum Number of Arrows to Burst Balloons LeetCode : ๐ฏ๐
There are some spherical balloons taped onto a flat wall. The balloons are represented as a 2D integer array, where each element represents a range on the x-axis. Arrows can be shot up from the x-axis to burst the balloons. Find the minimum number of arrows needed to burst all the balloons. -
Sort the People LeetCode : ๐ข๐ฅ
Given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each indexi
,names[i]
andheights[i]
denote the name and height of theith
person. Return names sorted in descending order of heights. -
Maximum Ice Cream Bars LeetCode : ๐๐ฆ
On a summer day, a boy wants to buy some ice cream bars. Given an array costs of lengthn
, wherecosts[i]
is the price of theith
ice cream bar in coins. The boy initially has coins to spend, and he wants to buy as many ice cream bars as possible. Return the maximum number of ice cream bars the boy can buy with coins. -
Plus One LeetCode : ๐
Given a large integer represented as an integer array digits, where eachdigits[i]
is theith
digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading0
's. Increment the large integer by one and return the resulting array of digits. -
Gas Station LeetCode : โฝ
Given two arrays representing a circular journey withn
gas stations:gas
andcost
. Our car has an unlimited gas tank and it costs a certain amount of gas to travel from one station to the next. Find the index of the gas station where we can start the journey and complete the circuit once. Return-1
if it is not possible. -
Keyboard Row LeetCode : ๐ป
Given an array of stringswords
, return the words that can be typed using letters of the alphabet on only one row of American keyboard like: first row is"qwertyuiop"
, second row is"asdfghjkl"
, and third row is"zxcvbnm"
. -
Max Points on a Line LeetCode : ๐ข๐
Given an array ofpoints
wherepoints[i] = [xi, yi]
represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. -
Minimum Difference Between Highest and Lowest of K Scores LeetCode : ๐ผ๐ฝ
Given an arraynums
, wherenums[i]
represents the score of theith
student, with an integerk
. Pick the scores of anyk
students from the array so that the difference between the highest and the lowest of thek
scores is minimized. Return the minimum possible difference. -
Binary Tree Preorder Traversal LeetCode : ๐ณ๐๐
Given theroot
of a binary tree, return the preorder traversal of its nodes' values. -
Maximum Average Subarray I LeetCode : โซโณ
Given an integer arraynums
consisting ofn
elements, and an integerk
. Find a contiguous subarray whose length is equal tok
that has the maximum average value and return this value. Any answer with a calculation error less than10-5
will be accepted. -
Same Tree LeetCode : ๐ณ๐ณ
Given the roots of two binary treesp
andq
, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. -
Contains Duplicate II LeetCode : ๐๐
Given an integer arraynums
and an integerk
, returntrue
if there are two distinct indicesi
andj
in the array such thatnums[i] == nums[j]
andabs(i - j) <= k
. -
Minimum Time to Collect All Apples in a Tree LeetCode : ๐๐
Given an undirected tree consisting ofn
vertices numbered from0
ton-1
, which has some apples in their vertices. You spend 1 second to walk over one edge of the tree. Return the minimum time in seconds you have to spend to collect all apples in the tree, starting at vertex 0 and coming back to this vertex. -
Intersection of Two Arrays LeetCode : โ
Given two integer arraysnums1
andnums2
, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. -
Number of Nodes in the Sub-Tree With the Same Label LeetCode : ๐ณ๐๐จ
Given a tree with n nodes labeled by lower-case characters. Each node has a label specified in the stringlabels
, and the edges of the tree are given in the arrayedges
. The task is to return an array of sizen
, where each element is the number of nodes in the subtree of the corresponding node that have the same label as the node itself. -
Max Consecutive Ones III LeetCode : ๐1๏ธโฃ
Given a binary arraynums
and an integerk
, return the maximum number of consecutive1
's in the array if you can flip at mostk
0
's. -
Longest Path With Different Adjacent Characters LeetCode : ๐ฒ๐ฃ๏ธ๐ณ
Given a tree represented by an array and a string, find the longest path in the tree such that no two adjacent nodes on the path have the same character assigned to them. -
Grumpy Bookstore Owner LeetCode : ๐ ๐
Given an arraycustomers
and an arraygrumpy
, wheregrumpy[i]
is1
if the bookstore owner is grumpy during theith
minute and0
otherwise. The bookstore owner knows a secret technique to keep themselves not grumpy for a certain number ofminutes
, but can only use it once. Return the maximum number of customers that can be satisfied throughout the day. -
Lexicographically Smallest Equivalent String LeetCode : ๐๐๐ค
Given two strings of the same lengths1
ands2
and a stringbaseStr
, using the equivalency information froms1
ands2
, return the lexicographically smallest equivalent string ofbaseStr
. -
Best Time to Buy and Sell Stock LeetCode : ๐ฐ๐๐
Maximize profit by buying and selling a stock on different days, return max profit or 0 if none. -
Number of Good Paths LeetCode : ๐ฃ๏ธ
Find the number of good paths in a tree, where a good path starts and ends at nodes with the same value and all nodes in between have values less than or equal to the starting node's value. The input is an array of node values and an array of edges representing the tree structure. -
Number of Arithmetic Triplets LeetCode : ๐ข๐
Find the number of unique arithmetic triplets(i, j, k)
in a strictly increasing integer array wherenums[j] - nums[i] == diff
andnums[k] - nums[j] == diff.
-
Insert Interval LeetCode : โฌ๏ธโ
The task is to insert a new interval into a given sorted array of non-overlapping intervals and merge any overlapping intervals if necessary, while keeping the array sorted. -
Flipping an Image LeetCode : ๐๐
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
E.g.[1,1,0]
->[0,1,1]
->[1,0,0]
-
Flip String to Monotone Increasing LeetCode : 0๏ธโฃ1๏ธโฃ๐
Given a binary string, flip the least number of times to make it monotone increasing (consists of 0's followed by 1's) and return that count. -
Find First Palindromic String in the Array LeetCode : ๐๐
Given an array of stringswords
, return the first palindromic string in the array. If there is no such string, return an empty string""
. -
Maximum Sum Circular Subarray LeetCode : ๐๐ฐ๐
Given a circular integer arraynums
of lengthn
, return the maximum possible sum of a non-empty subarray ofnums
. -
Maximum Count of Positive Integer and Negative Integer LeetCode : ๐
Get the maximum count of positive and negative integers in a given array and return the maximum count. -
Binary Search LeetCode : 1๏ธโฃโ2๏ธโฃ
Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. -
Subarray Sums Divisible by K LeetCode : ๐ข๐
Given an integer arraynums
and an integerk
, return the number of non-empty subarrays that have a sum divisible byk
. A subarray is a contiguous part of an array. -
Count Number of Nice Subarrays LeetCode : ๐งฎ๐
Given an array of integersnums
and an integerk
. A continuous subarray is called nice if there arek
odd numbers on it. Return the number of nice sub-arrays. -
Non-decreasing Subsequences LeetCode : ๐
Given an integer arraynums
, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may return the answer in any order. -
Sum of All Subset XOR Totals LeetCode : โจ
Given an array of integers, return the sum of XOR of all subsets. Count subsets with same elements multiple times. -
Restore IP Addresses LeetCode : ๐ ๏ธ๐
A valid IP address consists of 4 integers between 0 and 255, separated by dots, no leading zeros. Given a string of digits, return all possible valid IP addresses that can be formed by inserting dots, no reordering or removing digits in the string. -
Palindrome Partitioning LeetCode : ๐๐จ๐งฑ
Given a strings
, partitions
such that every substring of the partition is a palindrome. Return all possible palindrome partitioning ofs
. -
Assign Cookies LeetCode : ๐ช
You want to give your children cookies, with each child getting at most one. Each child has a "greed factor" for cookie size, and you have cookies of various sizes. You want to assign the cookies to the children to make the most content children. -
Minimum Common Value LeetCode : ๐๐๐
Given two sorted integer arrays, return minimum common integer from sorted arraysnums1
andnums2
, or-1
if none. -
Find the Town Judge LeetCode : ๐๏ธ
Find the town judge amongn
people, using trust arraytrust[i]=[ai, bi]
. Return their label if they trust no one and are trusted by everyone except themselves, else return-1
. -
Predict the Winner LeetCode : ๐
Given an integer arraynums
, two players take turns choosing numbers from either end of the array, adding to their score until the array is empty. Return true if Player 1 can win assuming optimal play. -
Snakes and Ladders LeetCode : ๐๐ฒ๐ช
Find the minimum number of moves to reach the end of a snakes and ladders board where each cell is labeled in a Boustrophedon style. The algorithm uses breadth-first search and returns-1
if the end cannot be reached. -
Find Closest Node to Given Two Nodes LeetCode : ๐ฑ
โ๏ธ โญ
Given a directed graph with n nodes, represented by an array of edges and two starting nodes, find the closest node that can be reached from both nodes with minimized maximum distance. If multiple answers, return smallest index. Return -1 if no possible answer. -
Reverse Linked List LeetCode : ๐๐๐
Given the head of a singly linked list, reverse the list, and return the reversed list. -
Cheapest Flights Within K Stops LeetCode : โ
Find the cheapest route fromsrc
todst
with at mostk
stops amongn
cities connected by flights, return-1
if no such route exists. -
Roman to Integer LeetCode : โก๏ธ๐ข
Given a roman numeral, convert it to an integer. Roman numerals have 7 symbols: I, V, X, L, C, D, M. Each symbol represents a different value. The algorithm for converting Roman numerals to integers is adding together the values of each symbol, handling special cases of subtraction such as IV and IX. -
Missing Number LeetCode : โ
Given an arraynums
containingn
distinct numbers in the range[0, n]
, return the only number in the range that is missing from the array. -
Concatenated Words LeetCode :
โถ๏ธ โฉ
Given an array of stringswords
(without duplicates), return all the concatenated words in the given list ofwords
. A concatenated word is defined as a string that is comprised entirely of at least two shorter words in the given array. -
Data Stream as Disjoint Intervals LeetCode : ๐๐๐ณ๐ฒ
Implement aSummaryRanges
class that can: Initialize with an empty stream, add integers to the stream and return a summary of the integers in the stream as a list of disjoint intervals, sorted by start interval. -
Closest Prime Numbers in Range LeetCode : 3๏ธโฃโฉ5๏ธโฃ
Find the closest prime numbers betweenleft
andright
, where closest is defined as minimum difference between the two prime numbers. Return the pair as an array or[-1, -1]
if no such pair exists. Prime numbers are defined as numbers only divisible by1
and themselves. -
LFU Cache LeetCode : ๐พ
Design and implement a LFU cache data structure. Implement theLFUCache
class withget
andput
methods that haveO(1)
time complexity. -
Sqrt(x) LeetCode : ๐งฎ๐ข
Find square root of x rounded down to nearest integer. No built-in functions or operators allowed. -
Happy Number LeetCode : ๐
Determine if a number is happy by summing its digits' squares and repeating until 1 or an endless cycle. Return true if it ends in 1, false otherwise. -
N-th Tribonacci Number LeetCode : ๐ข๐
The Tribonacci sequence is defined as: T0 = 0, T1 = 1, T2 = 1, Tn+3 = Tn+Tn+1+Tn+2 forn >= 0
. Givenn
, return Tn. -
Climbing Stairs LeetCode : ๐ช
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? -
Best Team With No Conflicts LeetCode : ๐โฝ๏ธ๐ช
You're a basketball manager. For a tournament, you want to pick the team with the highest score by summing the scores of all players. Conflicts occur when a younger player has a higher score than an older player. Choose the best team with no conflicts using lists of player scores and ages. -
Fizz Buzz LeetCode : ๐ฅ๐
Return a string array of "FizzBuzz" ifi
is divisible by3
&5
, "Fizz" if divisible by3
, "Buzz" if divisible by5
, ori
(as string) for alli
from1
ton
, indexed 1-based. -
Greatest Common Divisor of Strings LeetCode : ๐โ๏ธ๐ก
Find largest stringx
that divides bothstr1
andstr2
. If t divides s,s = t + ... + t
(t repeated one or more times). -
Power of Three LeetCode : ๐ก๏ธโก๏ธ3๏ธโฃ
Given an integern
, returntrue
if it is a power of three. Otherwise, returnfalse
. An integern
is a power of three, if there exists an integerx
such thatn == 3x
. -
Zigzag Conversion LeetCode : โก๐ญ
Write code to convert string"PAYPALISHIRING"
to"PAHNAPLSIIGYIR"
using zigzag pattern given number of rows:string convert(string s, int numRows)
-
Permutation in String LeetCode : ๐๐งต
Given two stringss1
ands2
, returntrue
ifs2
contains a permutation ofs1
, orfalse
otherwise. In other words, returntrue
if one ofs1
's permutations is the substring ofs2
. -
Find All Anagrams in a String LeetCode : ๐๐๐ค
Given two stringss
andp
, return an array of all the start indices ofp
's anagrams ins
. You may return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. -
Fruit Into Baskets LeetCode : ๐๐๐๐๏ธ
Two baskets are given to collect fruit from a row of trees, represented by anarray
fruits. Each basket can only hold one type of fruit, with no limit on the amount. You must pick one fruit from each tree as you move from left to right, and stop when you reach a fruit that won't fit in the baskets. The goal is to pick the maximum number of fruits. -
Jump Game II LeetCode : ๐โโ๏ธ๐ฎ2๏ธโฃ
Given a 0-indexed arraynums
of lengthn
, starting atnums[0]
. Eachnums[i]
is the max jump length fromi
toi + j
(where0 <= j <= nums[i]
andi + j < n
). Return minimum number of jumps to reachnums[n - 1]
. Assumed to always have a solution. -
Naming a Company LeetCode : ๐๐ก๐ข
Given an array of stringsideas
representing company names, find the number of distinct names formed by swapping the first letters of two names and concatenating them if they are not in the originalideas
list. -
As Far from Land as Possible LeetCode : ๐๐โโ๏ธ๐๏ธ
Find max Manhattan distance from water cell to nearest land cell in ann x n
grid of0
s (water) and1
s (land). Return distance or-1
if no water or land exists. -
Intersection of Two Arrays II LeetCode : ๐2๏ธโฃ๐งฎ
Given two integer arraysnums1
andnums2
, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order. -
Binary Tree Inorder Traversal LeetCode : ๐ณ
Given theroot
of a binary tree, return the inorder traversal of its nodes' values. -
Add Binary LeetCode : 1๏ธโฃโ0๏ธโฃ
Given two binary stringsa
andb
, return their sum as a binary string. -
Add to Array-Form of Integer LeetCode : ๐โ๐ข
Given an integer arraynum
representing digits of an integer. Add another integerk
tonum
and return the sum of both integers as an array of digits in left-to-right order. -
Minimum Distance Between BST Nodes LeetCode : ๐ณ๐๐
Given theroot
of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree. -
Invert Binary Tree LeetCode : ๐ณ๐๐ป
Given theroot
of a binary tree, invert the tree, and return its root. -
Binary Tree Zigzag Level Order Traversal LeetCode : ๐ณโก๏ธ๐ถโโ
Given theroot
of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between). -
Spiral Matrix LeetCode : ๐๐ข
Given anm x n
matrix
, return all elements of thematrix
in spiral order. -
Search Insert Position LeetCode : ๐
โคต๏ธ ๐
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. The runtime complexity of the algorithm must beO(log n)
. -
Single Element in a Sorted Array LeetCode : ๐ก1๏ธโฃ๐ง๐ข
Given a sorted array of integers where all elements appear twice, except for one element that appears once, return the single element. The solution must have a time complexity ofO(log n)
and a space complexity ofO(1)
. -
Single Number LeetCode : ๐ข๐ค1๏ธโฃ
Find the unique number in an array of integers where every element appears twice, except for one. The solution must have a linear runtime complexity and use only constant extra space. -
Capacity To Ship Packages Within D Days LeetCode : ๐ข๐ฆ๐
A conveyor belt has packages with weights that must be shipped within days. We load the ship each day with packages in the order given by weights, but can't exceed the maximum weight capacity of the ship. Find the least weight capacity needed to ship all packages within the given timeframe. -
Pascal's Triangle LeetCode : ๐งโ๐ฌ๐ข๐บ
Given an integernumRows
, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it. -
Valid Anagram LeetCode : ๐ค๐๐กโ
Given two stringss
andt
, returntrue
ift
is an anagram ofs
, andfalse
otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. -
Valid Parentheses LeetCode : โ ( ) [ ] { }
Check if a string of brackets is valid by verifying that they are correctly opened and closed in the right order and that each opening bracket has a corresponding closing bracket. -
Basic Calculator II LeetCode : ๐งฎ
Given a strings
which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. -
Edit Distance LeetCode : ๐คโ๏ธ๐ก
Given two strings, return the minimum number of operations to convert one to the other using insert, delete, or replace operations on characters. -
String to Integer (atoi) LeetCode : ๐งตโก๏ธ๐ข
ThemyAtoi
function converts a string to a 32-bit signed integer by removing leading whitespace, reading an optional sign, extracting digits until the end of the input or a non-digit character, converting them to an integer, and clamping it if it's out of range. Return the integer as the final result. -
Number of Islands LeetCode : ๐๐๏ธ๐
Given anm x n
2D binary gridgrid
which represents a map of'1'
s (land) and'0'
s (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. -
Number of Islands LeetCode : ๐๐๐
Given thehead
of a singly linked list, returntrue
if it is a palindrome orfalse
otherwise. -
Convert Sorted Array to Binary Search Tree LeetCode : ๐ข๐ป๐ณ
Given an integer arraynums
where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. -
Symmetric Tree LeetCode : ๐ณ๐๐ณ
Given theroot
of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). -
Binary Tree Level Order Traversal LeetCode : ๐ณ๐ข๐
Given theroot
of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).