# Leetcode Detailed Solutions

## Leetcode 19: Remove Nth Node From End of List

Category: Medium Problem Given the head of a linked list, remove the nth node from the end of the list and return its head. Follow up: Could you do this in one pass? https://leetcode.com/problems/remove-nth-node-from-end-of-list Examples Example 1: Example 2: Example 3: Solution Approach In this problem of “remove nth node from the list”, we are given a linked list whose […]

## Leetcode 66: Plus one

Category: Easy Problem Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit. You may assume the integer does not contain any leading zero, except the

## Leetcode 2: Add Two Numbers

Category: Medium Problem You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself.

## Leetcode 169: Majority Element

Category: Easy Problem Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majority element always exists in the array. https://leetcode.com/problems/majority-element/description/ Examples Example 1: Example 2: Solution Approach In this problem, we have to find

## Leetcode 36: Valid Sudoku

Category: Medium Problem Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must contain the digits 1-9 without repetition. Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without repetition. Note: A Sudoku board (partially filled) could be

## Leetcode 11: Container With Most Water

Category: Medium Problem Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the

## Leetcode 1389: Create Target Array in the Given Order

Category: Easy Problem Given two arrays of integers nums and index. Your task is to create target array under the following rules: Initially target array is empty. From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array. Repeat the previous step until there are no elements to read in nums and index. Return the target array. It is guaranteed that the insertion operations will be

## Leetcode 441: Arranging Coins

Category: Easy Problem You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be formed. n is a non-negative integer and fits within the range of a 32-bit signed integer. https://leetcode.com/problems/arranging-coins/ Examples: Example 1 Example 2 Solution

## Leetcode 1502: Can Make Arithmetic Progression From Sequence

Category: Easy Problem Given an array of numbers arr. A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same. Return true if the array can be rearranged to form an arithmetic progression, otherwise, return false. https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/ Examples Example 1: Example 2: Constraints 2 <= arr.length <= 1000 -10^6 <= arr[i] <=

## Leetcode 1207: Unique Number of Occurrences

Category: Easy Problem Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. https://leetcode.com/problems/unique-number-of-occurrences/ Examples: Example 1 Example 2 Example 3 Constraints: 1 <= arr.length <= 1000 -1000 <= arr[i] <= 1000 Solution Approach In this problem, we need to find if