返回顶部
摘要: 给定长度为 n 的整数数组 nums,其中 n > 1,返回输出数组 output ,其中 output[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积。 示例: 输入: [1,2,3,4]输出: [24,12,8,6]说明: 请不要使用除法,且在 O(n) 时间复杂度内完成此题。 阅读全文
posted @ 2019-07-27 22:43 Swetchine 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点,你将只被给定要求被删除的节点。 现有一个链表 -- head = [4,5,1,9],它可以表示为: 示例 1: 输入: head = [4,5,1,9], node = 5输出: [4,1,9]解释: 给定你链表中值为 5 的第二个节点, 阅读全文
posted @ 2019-07-27 21:53 Swetchine 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 编写一个程序,找到两个单链表相交的起始节点。 如下面的两个链表: 在节点 c1 开始相交。 示例 1: 输入:intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3输出:Reference 阅读全文
posted @ 2019-07-27 19:40 Swetchine 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 给定一个二叉搜索树(Binary Search Tree),把它转换成为累加树(Greater Tree),使得每个节点的值是原来的节点值加上所有大于它的节点值之和。 例如: 输入: 二叉搜索树: 5 / \ 2 13 输出: 转换为累加树: 18 / \ 20 13 思路:二叉树的中序遍历结果就是 阅读全文
posted @ 2019-07-27 17:32 Swetchine 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe 阅读全文
posted @ 2019-07-27 12:36 Swetchine 阅读(102) 评论(0) 推荐(0) 编辑