摘要: 题目: Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may a 阅读全文
posted @ 2017-06-02 15:35 Sindyang 阅读(132) 评论(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 t 阅读全文
posted @ 2017-05-09 10:30 Sindyang 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目: Reverse a singly linked list. 思路: 以1—>2->3->4为例,链表反转的过程如下: 第一次循环结束: head: 2->3->4->NULL newhead: 1->NULL 第二次循环结束: head: 3->4->NULL newhead: 2->1-> 阅读全文
posted @ 2017-05-04 13:04 Sindyang 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 阅读全文
posted @ 2017-05-04 10:49 Sindyang 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 题目: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exi 阅读全文
posted @ 2017-04-27 20:41 Sindyang 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 题目: 141.Given a linked list, determine if it has a cycle in it. 142.Given a linked list, return the node where the cycle begins. If there is no cycle, 阅读全文
posted @ 2017-04-23 11:58 Sindyang 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is l 阅读全文
posted @ 2017-03-19 17:40 Sindyang 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目: 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 exc 阅读全文
posted @ 2017-03-11 17:15 Sindyang 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would hav 阅读全文
posted @ 2017-02-18 18:55 Sindyang 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted i 阅读全文
posted @ 2017-02-17 23:42 Sindyang 阅读(133) 评论(0) 推荐(0) 编辑