摘要:
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 first two lists.一直没想出原址排序... 阅读全文
摘要:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分治是比较好而且容易想到的思路。 1 class Solution { 2 public: 3 T... 阅读全文
摘要:
A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
摘要:
You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
摘要:
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.简单题,注意逻辑顺序就好了。 1 class Solution { 2 public: 3 ListNode *d... 阅读全文
摘要:
Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
摘要:
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,... 阅读全文
摘要:
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 in or... 阅读全文
摘要:
Given a binary tree, return theinordertraversal of its nodes' values.和preorder是一样的,把左子节点一直压入到栈中,直到没有左子节点为止,然后出栈访问,存储右子节点。 1 vector inorderTraversal(Tr... 阅读全文