Python strings are one of the most common data types you’ll encounter as you begin your coding journey. They are sequences of characters, meaning each string is essentially an ordered collection of individual characters. Python treats strings as immutable, which means once you create a string, you cannot modify it directly. However, Python provides powerful tools like indexing and slicing...
LeetCode 6 Solution – ZigZag Conversion
In the LeetCode 6 – “Zigzag Conversion” problem, we are given a string s and an integer numRows. The string should be written in a zigzag pattern across numRows rows. After forming this zigzag pattern, the task is to read the characters row by row and return the resulting string. For example, with the input string "PAYPALISHIRING" and numRows = 3, the zigzag pattern looks like:...
LeetCode 5 Solution: Longest Palindromic Substring
LeetCode 5 Solution – The Longest Palindromic Substring: the problem asks us to find the longest substring within a given string s that reads the same forwards and backwards. A palindrome is a word or sequence of characters that is identical when reversed. For example, in the string "babad", both "bab" and "aba" are palindromic substrings, with a length of 3. Given a string s...