Valid Word Abbreviation Leetcode solution using JAVA language
Valid word abbreviation problem will be solved by using 2 pointer approach, it has certain limitations: - abbreviation must not contain leading zeros - example: word: laughing out loud abbr: l07outl explanation: because of 0 before 7 it's not valid abbreviation, why? due to the start of the digits in abbr with zero, which is called leading zero. - adjacent substrings in the abbreviation is not accepted - example: word: as soon as possible abbr: a42e explanation: soon and as are adjaced substring, and abbreviation of soon and as is 42 collectively, which is not allowed. - replacing an empty substring is not allowed - example: word: abbreviation abbr: a0bbreviation explanation: zero between a and b is a replacement of empty substring which is not allowed Solution approach: - we will take two pointers (i and j), and i will be pointing to the start of the "word" and j will be pointing to the start of the "abbreviation" - ...