Leetcode 408: Valid Word Abbreviation

Problem Statement Description A string can be abbreviated by replacing any number of non-adjacent, non-empty substrings with their lengths. The lengths should not have leading zeros. For example, a string such as "substitution" could be abbreviated as (but not limited to): "s10n" ("s ubstitutio n") "sub4u4" ("sub stit u tion") "12" ("substitution") "su3i1u2on" ("su bst i t u ti on") "substitution" (no substrings replaced) The following are not valid abbreviations:...

August 23, 2023 · 3 min · 512 words · Me

Leetcode 876: Middle of the Linked List

Problem Statement Description Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. Examples Example 1: flowchart LR a((1))-->b((2))-->c(3)-->d((4))-->e((5)) Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: The middle node of the list is node 3. Example 2: flowchart LR a((1))-->b((2))-->c((3))-->d(4)-->e((5))-->f((6)) Input: head = [1,2,3,4,5,6] Output: [4,5,6] Explanation: Since the list has two middle nodes with values 3 and 4, we return the second one....

January 17, 2023 · 3 min · 487 words · Me

Leetcode 125: Valid Palindrome

Problem Statement A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanation: "amanaplanacanalpanama" is a palindrome. Example 2: Input: s = "race a car" Output: false Explanation: "raceacar" is not a palindrome....

January 10, 2023 · 2 min · 217 words · Me