Skip to content

Instantly share code, notes, and snippets.

View jianminchen's full-sized avatar

Jianmin Chen jianminchen

View GitHub Profile
@jianminchen
jianminchen / 2476ClosestNodes.cs
Created November 8, 2023 02:43
2476 Closest nodes queries in a binary search tree - TLE error, tree's height is O(N), not O(logN). It is better to save in the array, and apply binary search
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2476_closest_nodes
{
class Program
{
@jianminchen
jianminchen / 2049CountNodesWithHighestScore
Created October 31, 2023 00:03
2049 Count node with highest score
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _2049_count_nodes_with_the_highest_score
{
class Solution
{
@jianminchen
jianminchen / 282ExpressionAddOperators.cs
Created October 26, 2023 19:49
282 Expression Add operators - C# solution | DFS | * high precedence above +/- |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _282_expression_add_operators_III
{
class Program
{
@jianminchen
jianminchen / 536ConstructBinaryTreeFromString.cs
Created October 16, 2023 22:02
C# | Construct binary tree from string | Using stack | Ask questions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _536_quick_learner___stack
{
class Program
{
@jianminchen
jianminchen / 1547MinimumCut.cs
Created October 14, 2023 02:26
1547 Minimum cost to cut a stick - C# - extra requirement - find path as well
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1547_minimum_cut
{
class Program
@jianminchen
jianminchen / 1361ValidateBinaryTreeNodes.cs
Created September 20, 2023 23:18
1361 validate binary tree nodes - C# solution
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1361_Validate_binary_tree_nodes
{
class Program
{
@jianminchen
jianminchen / 1351ValidateBinaryTreeNodes.cs
Created September 20, 2023 20:04
1351 Validate binary tree nodes - C# solution
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1361_Validate_binary_tree_nodes
{
class Program
{
@jianminchen
jianminchen / 536ConstructBinaryTreeFromString.cs
Created September 19, 2023 01:31
536 Construct binary tree from string - Sept. 18, 2023
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _536_constructBinaryTreeFromString
{
class Program
{
@jianminchen
jianminchen / 1902DepthOfBSTGivenInsertionOrder.cs
Created September 14, 2023 22:28
1902. Depth of BST Given Insertion Order | Time out TLE 65/70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1902_depthBSTGivenInsertionOrder
{
class Program
{
@jianminchen
jianminchen / Leetcode742ClosestLeafInABinaryTree.cs
Last active September 13, 2023 02:27
742. Closest Leaf in a Binary Tree - practice with a test case
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _742_closest_leaf_in_a_binary_tree
{
class Program