摘要:
传送门:http://hihocoder.com/problemset/problem/1104解题思路: 这是一道树上的动态规划问题 首先将多叉树转化为二叉树存储,再根据题中推荐访问的村庄地点预先处理得到必须访问的村庄集合,以便在动态规划时使用辅助决策,根据状态转移方程求解。 1 #includ... 阅读全文
摘要:
Problem:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid ... 阅读全文
摘要:
Problem:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest fo... 阅读全文
摘要:
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,... 阅读全文
摘要:
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity1. Naive Solution思路:直接的想法依次找出列表中的最小项串接起来。 复杂度分析:时间复杂度... 阅读全文
摘要:
Problem Description:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre... 阅读全文
摘要:
Problem Description:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node do... 阅读全文
摘要:
Problem Description:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Popul... 阅读全文
摘要:
Problem Description:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your pr... 阅读全文