Given a set of expression with > and < and unknown variable, check if they are true:
for example
a<b, b<c, a<c => True
a<b, b<c, c<a => falseSeems dfs or topology sort to check cycle can handle
follow up 1:
If not just only unknow variable, but also number ?
a>2, a<b, b<1 => falseProbably on top of previous one , for number additionaly sort them and add to graph like above also add linke 1-> 2
follow up 2:
What if we have =?
a>b, b<=a => false
a>=b, b>=c, c>=a => trueFor follow up 2, current my idea is to have have a edge struct to teel where it has equal of not , and using DFS to check:
I am not sure if follow up 2 my idea correcet or not, kindly comment on it.