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...
LeetCode #3 Solution: Longest Substring
LeetCode #3 Solution – Longest Substring Without Repeating Characters: The challenge is to find the length of the longest substring in a given string s that contains no repeating characters. A substring is a contiguous sequence of characters within a string. Examples: Input: s = “abcabcbb”Output: 3Explanation: The longest substring without repeating characters is...
LeetCode #2 solution: Adding two numbers
Problem: #2 adding two numbers LeetCode #2 solution – Adding Two Numbers: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except...