Link to problem Description Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Solution W...
Leetcode 904 - Fruit Into Baskets
Link to problem Description You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the t...
Leetcode 2870 - Minimum Number of Operations to Make Array Empty
Link to problem Description You are given a 0-indexed array nums consisting of positive integers. There are two types of operations that you can apply on the array any number of times: Choose...
Leetcode 171 - Excel Sheet Column Number
Link to problem Description Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> ...
Leetcode 1749 - Maximum Absolute Sum of Any Subarray
Link to problem Description You are given an integer array nums. The absolute sum of a subarray [s0, s1, ..., sn] is abs(s0 + s1 + ... + sn). Return the maximum absolute sum of any (possibly emp...
Leetcode 2487 - Remove Nodes from Linked List
Link to problem Description You are given the head of a linked list. Remove every node which has a node with a greater value anywhere to the right side of it. Return the head of the modified li...
Leetcode 1748 - Sum of Unique Elements
Link to problem Description You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. Return the sum of all the unique elements...
Leetcode 290 - Work Pattern
Link to problem Description Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a n...
Leetcode 538 - Convert BST to Greater Tree
Link to problem Description Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all k...
C/C++ Code Snippets
This post is about some C++ code snippets that might be useful when doing online assessment (and this post might continue to grow). Sometimes we just couldn’t remember how to do a certain operation...