We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It took me 2 days to learn about regex, NFA, DFA, and Thompson and subset construction and also 400 lines of code to accomplish this exercise :) I also think there is a somewhat simpler solution. You can use NFA construction right fron regex string like it is done here: http://algs4.cs.princeton.edu/54regexp/NFA.java.html. And then construct DFA from it without parsing regex to tree and then converting tree to NFA. Or even construct NFA without eps-transitions right fron the string. But it's quite convoluted I think.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Count Strings
You are viewing a single comment's thread. Return to all comments →
It took me 2 days to learn about regex, NFA, DFA, and Thompson and subset construction and also 400 lines of code to accomplish this exercise :) I also think there is a somewhat simpler solution. You can use NFA construction right fron regex string like it is done here: http://algs4.cs.princeton.edu/54regexp/NFA.java.html. And then construct DFA from it without parsing regex to tree and then converting tree to NFA. Or even construct NFA without eps-transitions right fron the string. But it's quite convoluted I think.