Quantcast
Channel: Guan Gui » linear time
Browsing latest articles
Browse All 6 View Live

Image may be NSFW.
Clik here to view.

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 Article



Image may be NSFW.
Clik here to view.

LeetCode 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 Article

LeetCode 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
Browsing latest articles
Browse All 6 View Live




Latest Images