![JAR search and dependency download from the Maven repository](/logo.png)
com_github_leetcode.neighbors.Node.kt Maven / Gradle / Ivy
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 - 2025 Weber Informatics LLC | Privacy Policy