JavaScript Solution

Best Time to Buy and Sell Stock II LeetCode Solution

You are given an integer array prices where prices[i] is the price of a given stock on the ith day. On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day. Find and return the maximum profit you can achieve.

Best Time to Buy and Sell Stock II LeetCode Solution Read More »

Two Sum LeetCode Solution

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice.

Two Sum LeetCode Solution Read More »

Contains Duplicate III LeetCode Solution

You are given an integer array nums and two integers indexDiff and valueDiff. Find a pair of indices (i, j) such that: i != j, abs(i – j) <= indexDiff. abs(nums[i] - nums[j]) <= valueDiff, and Return true if such pair exists or false otherwise.

Contains Duplicate III LeetCode Solution Read More »

Scroll to Top