Leetcode Medium Longest Palindromic Substring Java Problem Statement Given a string, Find the longest palindromic substring. Solution Explanation Understanding the question here is very simple, given a string RENTNOW, the substring NTN is a palindrome of length 3, and that would be the result. Brute Force Before we think of
Frequently Asked Questions Calculate the Hamming Distance between two Integers Problem Statement Given two integers, calculate the hamming distance between them. Solution Explanation Hamming Distance between integers is defined as the number of indexes where the two bits differ. For example, given integers x = 2 and y=5, the hamming distance between them is,
Array Trapping Rain Water Solution Java Problem Statement Given an a list of n integers which are non negative and represent an elevation map of various buildings where the width of each bar/building is 1, Find out how much water can be saved in between them when it rains.
Array Find Two Numbers in an Array Which Sum Up to K Problem Statement Given an array of integers, find out two indices such that the sum of the numbers at that indices matches K. For example, {4, 6, 8, 1, 9} and K = 15, the output would be [1,4] Solution Explanation The questions is
Linked List Check if a LinkedList has a cycle Problem Statement Given a single linked list, verify if the list has a cycle. A linked list has a cycle if a node's reference points back to an earlier node in the chain. Example: 1 -> 2 -> 3 -> 4
Array Three Sum(3Sum) Leetcode Problem Statement Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Solution Explanation Given an integer array like below,
Leetcode Easy Reverse a LinkedList Java Problem Statement Reverse a singly linked list. Given a single linked list, reverse it in place. Explanation Given a linked list like below, 1 -> 2 -> 3 -> 4 -> 5 We can use three pointers, to traverse through