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

com_github_leetcode.Node.kt Maven / Gradle / Ivy

package com_github_leetcode

class Node {
    var `val`: Int
    var neighbors: List

    constructor() {
        `val` = 0
        neighbors = ArrayList()
    }

    constructor(`val`: Int) {
        this.`val` = `val`
        neighbors = ArrayList()
    }

    constructor(`val`: Int, neighbors: List) {
        this.`val` = `val`
        this.neighbors = neighbors
    }

    override fun toString(): String {
        return neighbors.joinToString(separator = ",", prefix = "[", postfix = "]") { node ->
            if (node.neighbors.isEmpty()) {
                node.`val`.toString()
            } else {
                node.neighbors.joinToString(separator = ",", prefix = "[", postfix = "]") { nodeItem ->
                    nodeItem.`val`.toString()
                }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy