
半年更一个的OJ
Yinwhe
这个作者很懒,什么都没留下…
展开
-
ZigZagging on a Tree
ZigZagging on a Tree Created: Oct 29, 2020 12:09 AM Tags: OJ Origin problem Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences.原创 2020-10-29 15:19:46 · 645 阅读 · 0 评论 -
递归的记忆化搜索
递归的记忆化搜索 题目描述 对于一个递归函数w(a,b,c)w(a,b,c) 如果a≤0 or b≤0 or c≤0就返回值1. 如果a>20 or b>20 or c>20就返回w(20,20,20) 如果a<b并且b<c 就返回w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c) 其它的情况就返回w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1) 这是个简单的递归函数,但实现起来可能会有些问题。当a,b,c原创 2020-10-29 15:17:01 · 693 阅读 · 0 评论 -
寻找正序中位数
寻找正序中位数 题目描述: 给定两个大小为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。 请你找出这两个正序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。 难点 控制时间复杂度为O(log(m+n)) 主体思路 复杂的带log应该考虑设计二分查找 同化奇偶情况为:查找 (m+n)/2 的数和查找 (m+n)/2+1 的数 广义考虑查找第K个数: 假设两个有序数组分别是 A 和 B。要找到第 k 个元素原创 2020-10-29 15:15:50 · 103 阅读 · 0 评论