Valid Parentheses | Leetcode 20 Solution

Introduction The “Valid Parentheses” problem (Leetcode 20) is a popular question often asked in coding interviews. The task is to check if a given string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’ is valid. An input string is valid if the brackets are correctly closed and nested. In this blog post, … Read more

Longest Common Prefix | Leetcode 14 Solution

The Longest Common Prefix problem on Leetcode is a classic string manipulation problem. Here’s the problem statement: Problem Statement: Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”. Examples: Example 1: Example 2: Naive Solution: Compare Characters Iteratively Approach: … Read more

Roman to Integer – Leetcode 13 Solution

Roman to Integer

The “Roman to Integer” problem, Leetcode problem #13, is a classic interview question that tests your understanding of algorithms and data structures. In this problem, you’re tasked with converting a given Roman numeral string to an integer. Problem Description Roman numerals are represented by seven different symbols: For example: The challenge is to convert a … Read more

Valid Parentheses – Leetcode 20 Solution | Code & Explanation

Valid Parentheses – Leetcode 20 Solution in Java Leetcode’s “Valid Parentheses” problem is one of the classic questions in coding interviews, as it tests your knowledge of stacks and string manipulation. Let’s explore this problem, its requirements, and multiple solutions to solve it efficiently. Problem Statement Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the … Read more

Palindrome Number – LeetCode 9 Solution

A palindrome number reads the same forward and backward. This problem is a classic example of simple logic-based programming and is widely used in coding interviews to test problem-solving skills and understanding of fundamental concepts. In this blog post, we’ll explore various ways to solve the Palindrome Number problem (LeetCode 9) in Java. Problem Statement … Read more

How to solve Two Sum Problem | 2 Solutions

two sum problem

The Two Sum problem is one of the most popular algorithmic problems that is frequently asked in technical interviews. This problem tests your ability to think algorithmically and optimize for efficiency. In this article, we’ll break down the Two Sum problem, explore different approaches, and provide a complete Java solution. By the end, you’ll be … Read more

Leetcode 283 – Move Zeroes | Two Pointer

Move Zeroes

Problem Description: Given an integer array nums, move all 0‘s to the end of it while maintaining the relative order of the non-zero elements. Example 1: Example 2: Constraints: Move Zeroes – LeetCode Solution(s): To move all zeros to the end of an integer array while maintaining the relative order of the non-zero elements, you can follow … Read more

Leetcode 88- Merge Sorted Array | Two Pointer

Merge Sorted Array

Merging sorted arrays is a fundamental problem in computer science. The task is to combine two sorted arrays into one sorted array, maintaining the order. The Merge Sorted Array presents this classic problem with a twist — you are asked to merge the arrays in-place. This means that instead of using extra space, you must … Read more

Leetcode 27- Remove Element from Array

Leetcode 27- Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things: Custom Judge: The judge will test your … Read more