摘要:
Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq... 阅读全文
摘要:
Sort a linked list using insertion sort.题目意思是用插入排序对单链表进行排序,做法是返回一个新的单链表,每次插入的时候都添加一个新建的节点。/** * Definition for singly-linked list. * public class List... 阅读全文
摘要:
Sort a linked list inO(nlogn) time using constant space complexity.归并排序的基本思想是:找到链表的middle节点,然后递归对前半部分和后半部分分别进行归并排序,最后对两个以排好序的链表进行Merge。/** * Definitio... 阅读全文
摘要:
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 1 public class Solution { 2 public int reverse(int x) { 3 ... 阅读全文
摘要:
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文
摘要:
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep... 阅读全文
摘要:
There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[... 阅读全文
摘要:
There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
摘要:
Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
摘要:
Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文