# Tag: Leetcode

• ## Longest Valid Parentheses – Leetcode Python

Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring. Examples Input: s = “(()” Output: 2 Explanation: The longest valid parentheses substring is “()”.

• ## Longest Palindromic Substring Solution – Python LeetCode

The goal is to create all palindromes of even and odd lengths while keeping track of the longest palindrome seen so far. To make a palindrome with an odd length, For lengthier palindromes, fix a centre and expand in both directions, i.e. fix I (index) as the centre and two indices as i1 = i+1 and i2 = i-1. If i1 and i2 are equal, reduce i2 and raise i1 to get the maximum length.

• ## 3sum Closest Leetcode Solution – Leetcode Python

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

• ## Next Permutation Leetcode – Python Solution

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.