自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

leetcode 解题思路

FLAG必经之路

  • 博客(11)
  • 收藏
  • 关注

原创 Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 思路:recursion: 左边为空的时候,只返回右边的+1, 右...

2016-06-29 14:30:35 190

原创 Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false. Note: You may assume t...

2016-06-29 13:54:32 235

原创 Intersection of Two Arrays

Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [...

2016-06-29 13:35:40 209

原创 Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 思路:recursion,就是左边下面的互换好了,右边下面的也互换好了,再根部左右互换; /** * Definition for a ...

2016-06-29 13:12:50 203

原创 Moving Average from Data Stream

Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example, MovingAverage m = new MovingAverage(3); m.next(1) = 1 m.next(10) = ...

2016-06-29 12:48:53 365

原创 Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space. 思路:反向计算出来值,然后跟原来的值比较就可以了。注意:保存原来的值; public class Solution { public boolean isPalindrome(int x) { if(x < 0) retu

2016-06-29 11:43:14 188

原创 Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 思路1: traverse的方法,就是访问所有的点,然后记录一些信息,从而最...

2016-06-17 14:35:05 262

原创 Delete a node, only give access to that node.

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 -&gt; 2 -&gt; 3 -&gt; 4 and you are given the third node wit...

2016-06-12 00:15:26 245

原创 Remove Linked List Elements

Remove all elements from a linked list of integers that have valueval. ExampleGiven:1 --&gt; 2 --&gt; 6 --&gt; 3 --&gt; 4 --&gt; 5 --&gt; 6,val= 6Return:1 --&gt; 2 --&gt; 3 --&gt; 4 --&gt; 5 ...

2016-06-10 13:45:40 265

原创 Reverse Linked List

Reverse a singly linked list. Iterative 解法: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ c...

2016-06-08 10:50:13 382

转载 转载: 成大事的9种心态

每个人做人办事的手段都是不一样的,可以讲,一个人就有一种手段,一个人就有一种靠自己手段获得成功的途径。无数事实表明,有些人就是太过于自信,想念自己确认的手段能够解决任何问题,但不知道这种往往是起不到任何作用。因此,他们总觉得离成功的目标不是越来越近,而实际上越来越远。   人生的计划和行动,是需要靠章法来完成的,而不是靠一些怪招去谋划的。这就好比在拳击台比赛一样:两个拳手相互较量,激战正酣,进

2016-06-02 11:46:13 273

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除