In an interview I met an interesting question. But I could not answer it, and I did not find it on Google.
The question is:
You are provided with a data stream. By declaring a variable, you can find out if the data has a repetition or a loop.
Example data stream:
100100100100 0001000100010001 100100010001 10...0010....010....01(where 0....0 is 0^10^10^10)
How to solve this problem? Is there any algorithm for this kind of problem?
I think there should be two approaches to this problem
1. The longest recurring substring problem
, . suffix tree , . ,
suffix tree
2. ()
Longest repeated substring, .
Longest repeated substring
, 100100100100 :
100100100100
dict["1"]++ dict["10"]++ dict["100"]++ dict["1001"]++
.. . , .. 1 00100100100 :
1
00100100100
dict["0"]++ dict["00"]++ dict["001"]++ dict["0010"]++
.
, , .
Source: https://habr.com/ru/post/1692030/More articles:Warning: unlink () Resource is temporarily unavailable - phpThe best way to select data in a default default tree table is sqlAre there any programming languages in which int () rounds (rather than truncates)? - castingHow to parse this string in json or array format in PHP? - phpDisable compiler warning for specific template code - c ++DDD: final consistency and 1 to n relationships - domain-driven-designWhy MVC uses ModelState for the supplied model in GET - c #Passing ngFor variable to ngIf template - angularUITableView didEndDisplaying не вызывается при воспроизведении видео - iosAsp.Net MVC view does not display model changes made by controller - asp.net-mvcAll Articles