Graphs, graphs, graphs. Let's start from the very beginning. We need to store a graph somehow. We will talk about 3 main ways to store a graph later, for now imagine you only have the knowledge you currently have and try to hack your way to victory!

Hands-on Demo

Facebook has your social graph. Why don't you hack your own?
package com.yourself;
import java.util.List;
public class Graph {
public static class Edge {
public int from;
public int to;
public Edge(int from, int to) {
this.from = from; = to;
n - number of nodes in the graph
edges - contains edges of the graph of form {from: 0, to: 4}
note that node indices in this case are zero-based
public Graph(int n, List<Edge> edges) {
// Initialize your graph here
public boolean hasEdgeInBetween(int from, int to) {
// answer the query here
return false;

Check out the markdown file to see how this exercise is injected into the template.

Template Resources

markdowns/ What you are reading here is generated by this file. uses the Markdown syntax to render text, media and to inject programming exercises.

java-project A simple Java + Maven + JUnit project dedicated to run the programming exercise above. A project relies on a Docker image to run. You can find images on the Docker Hub or you can even build your own.

techio.yml This mandatory file describes both the table of content and the programming project(s). The file path should not be changed.

Visual and Interactive Content provides all the tools to embed visual and interactive content like a Web app or a Unix terminal within your contribution. Please refer to the documentation to learn more about the viewer integrations.

Create your playground on
This playground was created on, our hands-on, knowledge-sharing platform for developers.
Go to
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants