11 2017 档案

摘要:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except  阅读全文
posted @ 2017-11-28 17:48 SkyMelody 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twi 阅读全文
posted @ 2017-11-28 16:26 SkyMelody 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the 阅读全文
posted @ 2017-11-21 17:37 SkyMelody 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of 阅读全文
posted @ 2017-11-20 22:26 SkyMelody 阅读(95) 评论(0) 推荐(0) 编辑
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2017-11-08 18:50 SkyMelody 阅读(93) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a heightbalanced BST. 思路:二分法; 阅读全文
posted @ 2017-11-05 14:05 SkyMelody 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n 阅读全文
posted @ 2017-11-05 09:43 SkyMelody 阅读(85) 评论(0) 推荐(0) 编辑
摘要: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 th 阅读全文
posted @ 2017-11-05 09:29 SkyMelody 阅读(99) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-11-04 15:22 SkyMelody 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in 阅读全文
posted @ 2017-11-03 15:41 SkyMelody 阅读(98) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. 思路:我的想法是先用快慢指针判断是 阅读全文
posted @ 2017-11-03 15:07 SkyMelody 阅读(107) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list using insertion sort. 链表的插入排序 思路,递归到链表尾,然后循环插入; 阅读全文
posted @ 2017-11-03 06:42 SkyMelody 阅读(92) 评论(0) 推荐(0) 编辑
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, 阅读全文
posted @ 2017-11-02 13:50 SkyMelody 阅读(73) 评论(0) 推荐(0) 编辑
摘要:Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文
posted @ 2017-11-01 21:44 SkyMelody 阅读(86) 评论(0) 推荐(0) 编辑
摘要:Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 思路:快慢指针,设置一个走两步的快指针,和一个走一步的慢指针,如果有环,则它们一 阅读全文
posted @ 2017-11-01 12:50 SkyMelody 阅读(92) 评论(0) 推荐(0) 编辑