Java Solution

Permutations LeetCode Solution

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Search Insert Position LeetCode Solution

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.

Largest Rectangle in Histogram LeetCode Solution

Given an array of integers heights representing the histogram’s bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.

Sudoku Solver LeetCode Solution

Write a program to solve a Sudoku puzzle by filling the empty cells.

Search in Rotated Sorted Array LeetCode Solution

Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.

Next Permutation LeetCode Solution

Given an array of integers nums, find the next permutation of nums.

Substring with Concatenation of All Words LeetCode Solution

You are given a string s and an array of strings words. All the strings of words are of the same length. Return the starting indices of all the concatenated substrings in s. You can return the answer in any order.

Divide Two Integers LeetCode Solution

Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing dividend by divisor.

Find the Index of the First Occurrence in a String LeetCode Solution

Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

Remove Element LeetCode Solution

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed.

Reverse Nodes in k-Group LeetCode Solution

Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list.

Merge Two Sorted Lists LeetCode Solution

You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list.

Climbing Stairs LeetCode Solution

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?