Lastest Posts
-
Potential energy scan with Psi4 continue
physics quantum chemistry potential energy surface
Comments CountNH3 vs PH3
We all know in organic chemistry a carbon center can be chiral (or stero active). However, a nitrogen center can not be chiral. Why? It is because NR1R2R3 configuration can easier be converted to its mirror image under room temperate through inversion. This inversion happens on a fast time scale (ca. pico seconds)
-
Potential energy scan with PSI4
physics quantum chemistry potential energy surface
Comments CountIntra-molecular rotation
Polyatomic molecules often composed of two entities that are connected through a single bond. These two entities can rotate around the single bond, creating various conformations. Due to quantum mechanical interactions between these two entities, the conformations would have different energies.
-
Minimize Hamming Distance After Swap Operations
Comments CountDescription
-
Shortest Subarray with Sum at Least K
Comments CountDescription
Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.
-
Sliding Window Maximum
Comments CountDescription
-
Constrained Subsequence Sum
decreasing queue dynamic programming
Comments CountDescription
-
Stone Game VI
Comments CountDescription
-
Sum of Absolute Differences in a sorted Array
Comments CountDescription
-
Concatenation of Consecutive Binary Numbers
Comments CountDescription
-
Max Number of K-Sum Pairs
Comments CountDescription
-
Goal Parser Interpretation
Comments CountDescription
You own a Goal Parser that can interpret a string command. The command consists of an alphabet of “G”, “()” and/or “(al)” in some order. The Goal Parser will interpret “G” as the string “G”, “()” as the string “o”, and “(al)” as the string “al”. The interpreted strings are then concatenated in the original order.
-
Stone Game VII
Comments CountDescription
-
Partitioning into Minimum Number of Deci-Binary Numbers
Comments CountDescription
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.
-
Count of Matches in Tournament
Comments CountDescription
You are given an integer n, the number of teams in a tournament that has strange rules:
-
Jump Game VI
heap algorithm dynamic programming
Comments CountDescription
You are given a 0-indexed integer array nums and an integer k.
-
Maximum Erasure Value
Comments CountDescription
-
Reformat Phone Number
Comments CountDescription
-
Minimum Cost Tree From Leaf Values
Comments CountProblem description
Given an array arr of positive integers, consider all binary trees such that: Each node has either 0 or 2 children; The values of arr correspond to the values of each leaf in an in-order traversal of the tree. (Recall that a node is a leaf if and only if it has 0 children.) The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree respectively. Among all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node. It is guaranteed this sum fits into a 32-bit integer.
-
Shortest path with alternating colors
algorithm breadth first search
Comments CountProblem description
Consider a directed graph, with nodes labelled 0, 1, …, n-1. In this graph, each edge is either red or blue, and there could be self-edges or parallel edges.
-
Smallest Sufficient Team
algorithm NP Hard dynamic programming
Comments CountProblem description
In a project, you have a list of required skills req_skills, and a list of people. The i-th person people[i] contains a list of skills that person has.
-
Car Pooling
Comments CountProblem description
You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot turn around and drive west.)
-
Find in Mountain Array
leetcode algorithm binary search
Comments CountProblem description
(This problem is an interactive problem.)
-
Letter Tile Possibilities
Comments CountProblem description
-
Island Perimeter
Comments CountProblem description
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.
-
Number of Islands
leetcode algorithm depth first search
Comments CountProblem description
Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
-
Surrounded Regions
leetcode algorithm depth first search
Comments CountProblem description
Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.
-
Convert Sorted List to Binary Search Tree
leetcode algorithm binary search tree linked list
Comments CountProblem description
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
-
Shortest Common Supersequence
leetcode algorithm dynamic programming
Comments CountProblem description
Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If multiple answers exist, you may return any of them.
-
2019高考数学最后一题
Comments Count已知a, b, c为正数,且满足abc=1. 证明: \begin{align} \frac{1}{a} + \frac{1}{b} + \frac{1}{c} \le a^2 + b^2 + c^2 \end{align} 和 \begin{align} (a+b)^3 + (b+c)^3+ (c+d)^3 \ge 24 \end{align}
-
Ring Polymer Molecular Dynamics Derivation
Comments CountSchrodinger’s equations states that \begin{align} \frac{d}{dt}|\Psi_t \rangle = \frac{-i \cdot \hat H}{\hbar} \cdot |\Psi_t \rangle \end{align} A formal solution to the equation is \begin{align} |\Psi_t \rangle = e^{\frac{-i \cdot \hat Ht}{\hbar}} \cdot |\Psi_0 \rangle \end{align}
-
Liouville's Theorem derivation
Comments CountIn classical mechanics the liouville’s theorem states that the intgeral element \begin{align} \partial p_0 \partial q_0 = \partial p_t \partial q_t \end{align} where \(p_0, q_0\) and \(p_t, q_t\)are the generalized coordinates at time 0 and t, respectively.
-
Gas Station
Comments CountThere are N gas stations along a circular route, where the amount of gas at station i is gas[i].
-
Tutorial on Pressure Dependent Rate Constant Calculation (RRKM)
chemical kinetics RRKM quantum mechanics computational chemistry
Comments CountChemistry is made of reactions. One important perspective of chemical reaction is its rate (or how fast it goes). The rate is typically defined as the number of molecules change in unit time. For a simple elementary step, the rate can be expressed as product of a rate constant and reactants concentrations.
-
Check Completeness of a Binary Tree (LC958)
Comments CountSolution
-
Flip Equivalent Binary Trees (LC951)
Comments CountProblem description
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.
-
Complete Binary Tree Inserter
binary tree depth first search
Comments CountProblem description
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
-
Smallest Subtree with all the Deepest Nodes (LC865)
leetcode algorithm binary tree depth first search
Comments CountProblem description
Given a binary tree rooted at root, the depth of each node is the shortest distance to the root.
-
All Nodes Distance K in Binary Tree (LC863)
leetcode algorithm depth first search binary tree
Comments CountProblem description
We are given a binary tree (with root node root), a target node, and an integer value K.
-
Sum of Distances in Tree (LC834)
leetcode algorithm depth first search tree
Comments CountProblem description
An undirected, connected tree with N nodes labelled 0…N-1 and N-1 edges are given.
-
Vibronic Spectra from First-Principle
franck condon factor quantum mechanics computational chemistry gaussian
Comments CountVibronic spectra of molecules used to be hot research area of molecular science.
-
Python implementation of Hartree Fock (H2O 3-21G basis set)
hartree fock computational chemistry quantum mechanics
Comments CountComputational chemistry is always fascinating.
Being able to predict molecular properties, such as (dipole, charge distribution, geometry, vibrational frequencies, Infra-red spectrum, Raman spectrum, NMR spectrum, polarizability, … and so on) from the first principle exemplifies the powerfulness of modern computational chemistry / physics.
-
Python Density Functional Theory in 2D
quantum mechanics density functional theory python
Comments CountDensity Functional Theory in Python Code (2D External Potential)
-
Flip Binary Tree to Match Preorder Traversal (LC971)
depth first search preorder traversal binary tree
Comments CountProblem description
Given a binary tree with N nodes, each node has a different value from {1, …, N}.
-
Partition Array for Maximum Sum (LC1043)
dynamic programming leetcode algorithm
Comments CountProblem description
Given an integer array A, you partition the array into (contiguous) subarrays of length at most K. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
-
Robot Bounded In Circle (LC1041)
Comments CountProblem description
On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions:
-
Binary Tree Pruning (LC814)
leetcode algorithm binary tree depth first search post order traversal
Comments CountProblem description
We are given the head node root of a binary tree, where additionally every node’s value is either a 0 or a 1.
-
Minimum Distance Between BST Nodes (LC783)
leetcode algorithm in order traversal binary tree
Comments CountProblem description
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.
-
Insert into Binary Search Tree (LC701)
algorithm leetcode depth first search binary tree
Comments CountProblem description
Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST.
-
Maximum Width of Binary Tree (LC662)
Problem description
Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null.
-
Print Binary Tree (LC655)
binary tree recursion depth first search leetcode algorithm
Comments CountProblem description
Print a binary tree in an m*n 2D string array following these rules:
-
Course Schedule II (LC210)
leetcode algorithm topological sort breadth first search depth first search
Comments CountProblem description
There are a total of n courses you have to take, labeled from 0 to n-1.
-
Course Schedule (LC207)
leetcode algorithm topological sort depth first search breadth first search
Comments CountProblem description
There are a total of n courses you have to take, labeled from 0 to n-1.
-
Find Duplicate Subtrees (LC652)
leetcode algorithm depth first search binary tree
Comments CountProblem description
Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them.
-
Sum of Left Leaves (LC404)
leetcode algorithm binary tree depth first search tree traversal
Comments CountProblem description
Find the sum of all left leaves in a given binary tree.
-
House Robber III (LC337)
leetcode algorithm binary tree dynamic programming
Comments CountProblem description
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that “all houses in this place forms a binary tree”. It will automatically contact the police if two directly-linked houses were broken into on the same night.
-
Serialize and Deserialize Binary Tree (LC297)
leetcode algorithm binary tree
Comments CountProblem description
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
-
Lowest Common Ancestor of a Binary Tree (LC236)
leetcode algorithm binary tree recursion
Comments CountProblem description
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
-
Lowest Common Ancestor of a Binary Search Tree (LC235)
leetcode algorithm binary search tree
Comments CountProblem description
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
-
Kth Smallest Element in a BST (LC230)
leetcode algorithm binary search tree
Comments CountProblem description
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
-
Binary Search Tree Iterator (LC173)
leetcode algorithm binary search tree
Comments CountProblem description
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
-
Minimum Score Triangulation of Polygon (LC1039)
leetcode algorithm dynamic programming
Comments CountProblem description
Given N, consider a convex N-sided polygon with vertices labelled A[0], A[i], …, A[N-1] in clockwise order.
-
Binary Search Tree to Greater Sum Tree (LeetCode 1038)
leetcode algorithm binary search tree
Comments CountProblem Description
Given the root of a binary search tree with distinct values, modify it so that every node has a new value equal to the sum of the values of the original tree that are greater than or equal to node.val.
-
Is Subsequence (LeetCode 392)
algorithm leetcode two pointers
Comments CountProblem description
Given a string s and a string t, check if s is subsequence of t.
-
Best Time to Buy and Sell Stock (LeetCode 121)
Comments CountProblem Description
Say you have an array for which the ith element is the price of a given stock on day i.
-
Best Time to Buy and Sell Stock (II) (LeetCode 122)
Comments CountProblem description
Say you have an array for which the ith element is the price of a given stock on day i.
-
Online stock span (LeetCode 901)
Comments CountProblem description
Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of that stock’s price for the current day.
-
Base Ball Game (LeetCode 682)
Comments CountProblem description
You’re now a baseball game point recorder.
-
Delete Node in a BST (LeetCode 450)
Comments CountProblem description
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
-
Divide and conqur
Comments CountDivide and conqur is a very powerful scheme that can reduce the original problem into sub-problems, which can be recursively reduced to sub-sub-problems and solved.
-
Test
Comments CountTest. This is my first blog.