Tag

leet code solutions

40 posts

Leetcode Solution - Best Time to Buy and Sell Stock

Leetcode Solution - Best Time to Buy and Sell Stock

Problem Statement You are given an array prices where prices[i] is the price of…

Binary Tree - Level Order Traversal

Binary Tree - Level Order Traversal

Problem Statement Given a Binary tree, print out nodes in level order traversal…

Four Sum - Leet Code Solution

Four Sum - Leet Code Solution

Problem Statement Given an array nums of n integers and an integer target, are…

Leetcode - Rearrange Spaces Between Words

Leetcode - Rearrange Spaces Between Words

Problem Statement You are given a string text of words that are placed among…

Leetcode - Maximum Non Negative Product in a Matrix

Leetcode - Maximum Non Negative Product in a Matrix

Problem Statement You are given a rows x cols matrix grid. Initially, you are…

Leetcode - Split a String Into the Max Number of Unique Substrings

Leetcode - Split a String Into the Max Number of Unique Substrings

Problem Statement Given a string s, return the maximum number of unique…

Replace all spaces in a string with %20

Replace all spaces in a string with %20

Problem Statement Replace all spaces in a string with ‘%20’ (three characters…

Valid Palindrome - Leet Code Solution

Valid Palindrome - Leet Code Solution

Problem Statement Given a string, determine if it is a palindrome, considering…

Valid Anagrams - Leet Code Solution

Valid Anagrams - Leet Code Solution

Problem Statement Given two strings s and t , write a function to determine if t…

First Unique Character in a String - Leet Code Solution

First Unique Character in a String - Leet Code Solution

Problem Statement Given a string, find the first non-repeating character in it…

Reverse String - Leet Code Solution

Reverse String - Leet Code Solution

Problem Statement Write a function that reverses a string. The input string is…

Rotate Image - Leet Code Solution

Rotate Image - Leet Code Solution

Problem Statement You are given an n x n 2D matrix representing an image, rotate…

Move Zeroes - Leet Code Solution

Move Zeroes - Leet Code Solution

Problem Statement Given an array nums, write a function to move all 0’s to the…

Plus One - Leet Code Solution

Plus One - Leet Code Solution

Problem Statement Given a non-empty array of digits representing a non-negative…

Validate Sudoku - Leet Code Solution

Validate Sudoku - Leet Code Solution

Problem Statement Determine if a 9x9 Sudoku board is valid. Only the filled…

Intersection of Two Arrays-II - Leet Code Solution

Intersection of Two Arrays-II - Leet Code Solution

Problem Statement Given two arrays, write a function to compute their…

Single Number - Leet Code Solution

Single Number - Leet Code Solution

Problem Statement Given a non-empty array of integers, every element appears…

Find if Array contains Duplicate Number - Leet Code Solution

Find if Array contains Duplicate Number - Leet Code Solution

Problem Statement Given an array of integers, find if the array contains any…

Maximum Length of Subarray With Positive Product - Leet Code Solution

Maximum Length of Subarray With Positive Product - Leet Code Solution

Problem Statement Maximum Length of Subarray With Positive Product. Given an…

Rotate Array - Leet Code Solution

Rotate Array - Leet Code Solution

Problem Statement Given an array, rotate the array to the right by k steps…

Calculate Max Profit - Buy and Sell Stocks Multiple Times - Leet Code Solution

Calculate Max Profit - Buy and Sell Stocks Multiple Times - Leet Code Solution

Problem Statement Say you have an array prices for which the ith element is the…

Remove Duplicates from Sorted Array - Leet Code Solution

Remove Duplicates from Sorted Array - Leet Code Solution

Problem Statement Given a sorted array nums, remove the duplicates in-place such…

Swap Nodes Pairs in Link List - Leet Code Solution

Swap Nodes Pairs in Link List - Leet Code Solution

Problem Statement Given a linked list, swap every two adjacent nodes and return…

Three Sum - Leet Code Solution

Three Sum - Leet Code Solution

Problem Statement Given an array nums of n integers, are there elements a, b, c…

Three Sum Closest - Leet Code Solution

Three Sum Closest - Leet Code Solution

Problem Statement Given an array nums of n integers and an integer target, find…

Convert Roman to Integer number - Leet Code Solution

Convert Roman to Integer number - Leet Code Solution

Problem Statement Roman numerals are represented by seven different symbols: I…

Longest Common Prefix - Leet Code Solution

Longest Common Prefix - Leet Code Solution

Problem Statement Write a function to find the longest common prefix string…

Integer to Roman conversion - Leet Code Solution

Integer to Roman conversion - Leet Code Solution

Problem Statement Roman numerals are represented by seven different symbols: I…

Check whether an integer number given is palindrome or not - Leet Code Solution

Check whether an integer number given is palindrome or not - Leet Code Solution

Problem Statement Determine whether an integer is a palindrome. An integer is a…

Container with Most Water - Leet Code Solution

Container with Most Water - Leet Code Solution

Problem Statement Given n non-negative integers a1, a2, …, an , where each…

Remove nth Node from Last - Leet Code Solution

Remove nth Node from Last - Leet Code Solution

Problem Statement Given a linked list, remove the n-th node from the end of list…

Convert String to Integer - atoi - Leet Code Solution

Convert String to Integer - atoi - Leet Code Solution

Problem Statement Implement atoi which converts a string to an integer…

Check whether number is palindrome or not - Leet Code Solution

Check whether number is palindrome or not - Leet Code Solution

Problem Statement Determine whether an integer is a palindrome. An integer is a…

Zigzag Pattern String Conversion - Leet Code Solution

Zigzag Pattern String Conversion - Leet Code Solution

Problem Statement The string “PAYPALISHIRING” is written in a zigzag pattern on…

Reverse digits of a signed integer - Leet Code Solution

Reverse digits of a signed integer - Leet Code Solution

Problem Statement Given a signed integer, reverse digits of an integer. Return…

Longest Palindrome Substring - Leet Code Solution

Longest Palindrome Substring - Leet Code Solution

Problem Statement Given a string s, find the longest palindromic substring in s…

Find the Median of Two Sorted Arrays - Leet Code Solution

Find the Median of Two Sorted Arrays - Leet Code Solution

Problem Statement There are two sorted arrays nums1 and nums2 of size m and n…

Longest Substring without repeating characters - Leet Code Solution

Longest Substring without repeating characters - Leet Code Solution

Problem Statement Given a string, find the length of the longest substring…

Add two numbers(reverse order) link list Problem - Leet Code Solution

Add two numbers(reverse order) link list Problem - Leet Code Solution

Problem Statement You are given two non-empty linked lists representing two non…

Two Sum Problem - Leet Code Solution

Two Sum Problem - Leet Code Solution

Problem Statement Given an array of integers, return indices of the two numbers…