Checking if a list of strings can be chained

后端 未结 8 866
庸人自扰
庸人自扰 2021-01-31 23:45

Question

Implement a function bool chainable(vector v), which takes a set of strings as parameters and returns true if they

8条回答
  •  感情败类
    2021-02-01 00:03

    seperatedly check for "Is chainable" and is "cylcic"

    if it's to be cyclic it must be chainable first. you could do something like this:

    if (IsChainable)
    {
      if (IsCyclic() { ... }
    }
    

    Note: That's the case if you check only the first and last element of the chain for "cylic".

提交回复
热议问题