304 North Cardinal St.
Dorchester Center, MA 02124

# Category Leetcode Solution

## Single Number II LeetCode Solution

Problem – Single Number II LeetCode Solution Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1:…

## Find Minimum in Rotated Sorted Array II LeetCode Solution

Problem – Find Minimum in Rotated Sorted Array II LeetCode Solution Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become: [4,5,6,7,0,1,4] if it was rotated 4 times. [0,1,4,4,5,6,7] if it was rotated 7 times. Notice that rotating an array [a[0], a[1], a[2],…

## Reorder List LeetCode Solution

Problem – Reorder List LeetCode Solution You are given the head of a singly linked-list. The list can be represented as: Reorder the list to be on the following form: You may not modify the values in the list’s nodes.…

## Find Subarrays With Equal Sum LeetCode Solution

Problem – Find Subarrays With Equal Sum LeetCode Solution Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at different indices. Return true if these subarrays exist, and false otherwise. A subarray is a contiguous non-empty sequence of elements within an…

## Strictly Palindromic Number LeetCode Solution

Problem – Strictly Palindromic Number LeetCode Solution An integer n is strictly palindromic if, for every base b between 2 and n – 2 (inclusive), the string representation of the integer n in base b is palindromic. Given an integer n, return true if n is strictly palindromic and false otherwise. A string is palindromic if it reads the same forward and backward. Example 1: Example 2: Constraints:…

## Longest Nice Subarray LeetCode Solution

Problem – Longest Nice Subarray LeetCode Solution You are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0. Return the length of the longest nice subarray. A subarray is a contiguous part…

## Number of Ways to Reach a Position After Exactly k Steps LeetCode Solution

Problem – Number of Ways to Reach a Position After Exactly k Steps LeetCode Solution You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or…

## Check Distances Between Same Letters LeetCode Solution

Problem – Check Distances Between Same Letters LeetCode Solution You are given a 0-indexed string s consisting of only lowercase English letters, where each letter in s appears exactly twice. You are also given a 0-indexed integer array distance of length 26. Each letter in the alphabet is numbered from 0 to 25 (i.e. ‘a’ -> 0, ‘b’ ->…

## Maximum Number of Robots Within Budget LeetCode Solution

Problem – Maximum Number of Robots Within Budget LeetCode Solution You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The ith robot costs chargeTimes[i] units to charge and costs runningCosts[i] units to run. You are also given an integer budget. The total cost of running k chosen robots is equal…

## Maximum Rows Covered by Columns LeetCode Solution

Problem – Maximum Rows Covered by Columns LeetCode Solution You are given a 0-indexed m x n binary matrix mat and an integer cols, which denotes the number of columns you must choose. A row is covered by a set of columns if each cell in the row…