↧
A Beautiful Linear Time Python Regex Matcher via NFA
Figure 1. NFA for Regex Pattern “(ca*t|lion)+.*(dog)?” I came across a problem on leetcode a few days ago. It asked me to implement a simple regex (regular expression) matcher which supports both ‘.’...
View ArticleLeetCode in Swift: Largest Rectangle in Histogram
Problem Statement Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where...
View ArticleLeetCode in Swift: Longest Palindromic Substring
Problem Statement Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. Original...
View Article