Intersection of Two Arrays II Leetcode Solution

Problem Statement   In this problem two arrays are given and we have to find out the intersection of this two arrays and return the resultant array. Each element in the result should appear as many times as it shows in both arrays. The result can be in any order. Example …

Read more

Palindrome Linked List Leetcode Solution

In the problem “Palindrome Linked List”, we have to check whether a given singly integer linked list is a palindrome or not. Example   List = {1 -> 2 -> 3 -> 2 -> 1} true Explanation #1: The list is palindrome as all elements from the start and back are …

Read more

Valid Palindrome Leetcode Solution

Problem Statement   Given a string, we have to determine if it is a palindrome, considering only alphanumeric characters i.e. numbers and alphabets only. We also have to ignore cases for alphabet characters. Example “A man, a plan, a canal: Panama” true Explanation: “AmanaplanacanalPanama”  is a valid palindrome. “race a car” …

Read more

Reverse Vowels of a String Leetcode Solution

Problem Statement   In this problem a string is given and we have to reverse only the vowels of this string. Example “hello” “holle” Explanation: before reversing :  “hello” after reversing    :  “holle” “leetcode” “leotcede” Explanation: Approach 1 (Using Stack)   We just have to reverse the vowels present in input …

Read more

Rotate List Leetcode Solution

The problem Rotate List Leetcode Solution provides us a linked list and an integer. We are told to rotate the linked list to the right by k places. So if we rotate a linked list k places to the right, in each step we take the last element from the …

Read more

Count of Triplets With Sum Less than Given Value

Problem Statement   We have given an array containing N number of elements. In the given array, Count the number of triplets with a sum less than the given value. Example   Input a[] = {1, 2, 3, 4, 5, 6, 7, 8} Sum = 10 Output 7 Possible triplets are : …

Read more

Move All the Zeros to the End of the Given Array

Problem Statement   In the given array move all the zeros which are present in the array to the end of the array. Here there is always a way exist to insert all the number of zeroes to the end of the array. Example   Input 9 9 17 0 14 0 …

Read more