摘要:
Binary Tree PreOrder Traversal:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文
摘要:
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
摘要:
Sort a linked list using insertion sort.简单插入排序,先写个插入一个值到链表里的函数,再遍历整个链表,一个一个把值插入新链表中: 1 public ListNode insertionSortList(ListNode head) { 2 i... 阅读全文
摘要:
Merge Two Sorted Lists:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fi... 阅读全文
摘要:
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.对每个点,考察其他点与它组成的直线斜率,使用HashMap将斜率与点个数对应起来。需要注意的一点是特殊斜率... 阅读全文
摘要:
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
摘要:
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What constitutes... 阅读全文