Count Good Nodes in Binary Tree - Kotlin (Medium)Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree. Example 1: Input: root = [3,1,4,3,null,1,5] Output: 4 Exp...Feb 19, 2022 · 1 min readabhiculous.hashnode.dev
Balanced Binary Tree - KotlinGiven a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the left and right subtrees of every node differ in height by no more than 1. Example 1: Input: root = ...Feb 19, 2022 · 1 min readabhiculous.hashnode.dev
Trees Implementationclass Tree { data class Node(val value: Int) { var leftNode: Node? = null var rightNode: Node? = null } var rootNode: Node? = null fun insert(value: Int) { val newNode = Node(value) if (rootNode == n...Jan 22, 2022 · 3 min readabhiculous.hashnode.dev
Queue Implementation In Kotlin -Data Structure And AlgorithmsQueue are data structure that follows the FIRST IN, FIRST OUT (FIFO), ie the first element that is added to the queue is the first one to be removed. Elements are always added to the back and removed from the front. Think of it as a line of people, ...Jan 16, 2022 · 2 min readabhiculous.hashnode.dev
Stacks Implementation In Kotlin -Data Structure And AlgorithmsStack is an abstract data type with a bounded(predefined) capacity. It is a simple data structure that allows adding and removing elements in a particular order. Every time an element is added, it goes on the top of the stack and the only element tha...Jan 16, 2022 · 2 min readabhiculous.hashnode.dev