← Questions

Validate a Hamiltonian path given as strings

0
CognitionCodingLast asked Mar 2026

A coding interview question asked in Cognition's online assessment, last asked Mar 2026. It tests graphs, string parsing and validation.

You get three strings that describe an undirected graph and a proposed order of vertices: the vertex list, like "(A,B,C)", the edge list, like "(A-B,B-C)", and the order, like "(C,B,A)". Decide whether the order is a Hamiltonian path: it…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

graphs · string parsing · validation

Your code and the AI tutor open when you unlock this question.