All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com_github_leetcode.neighbors.Node.kt Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
package com_github_leetcode.neighbors

import java.util.StringJoiner

class Node(var `val`: Int) {
    constructor(i: Int, asList: List) : this(i) {
        this.neighbors = ArrayList(asList)
    }

    var neighbors: ArrayList = ArrayList()

    override fun toString(): String {
        val result = StringJoiner(",", "[", "]")
        for (node in neighbors) {
            if (node!!.neighbors.isEmpty()) {
                result.add(node.`val`.toString())
            } else {
                val result2 = StringJoiner(",", "[", "]")
                for (nodeItem in node.neighbors) {
                    result2.add(nodeItem!!.`val`.toString())
                }
                result.add(result2.toString())
            }
        }
        return result.toString()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy