自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(56)
  • 收藏
  • 关注

原创 [LeetCode]Sort Characters By Frequency

Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once.So 'e

2017-03-23 03:00:17 332

原创 [LeetCode]200. Number of Islands岛的数量

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu

2017-03-22 23:17:12 842

原创 [LeetCode] Flatten Binary Tree to Linked List

大象放入冰箱几步的思路处理这问题就好了1.把左子树弄平, 2. 插入到根节点和根节点的右子树之间,3. 重复1,2思路不难,代码上有点混乱,细节实现是:把root的左子树弄成flatten的 flatten(root.left),把右子树保存起来 temp=root.right,让root.right=root.left, 然后断掉左边,root.left=null.然后一直走到右边的

2014-10-07 05:57:06 1039

原创 [LeetCode] Pow(x,n)

这道题我的写法和别人可能不一样,总体思路是一样的第一步就是判断n的情况,如代码所示我是将指数n转化成二进制,比如说: 3^4545的二进制是101101从左到右扫一遍,跳过第一位。如果位是0,那么就将结果平方,也就是乘自己。如果位是1,那么除了要将结果平方,还要再乘一次x这个的原理是根据指数的性质,如果n=10(二进制),相当于2,如果n左移一位,就是再*2,也

2014-10-06 10:53:27 871

原创 [LeetCode] Longest Palindrome Substring 详细分析

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.面DP题的考官都是神经病。。(吐

2014-10-01 11:39:56 1720

原创 [LeetCode] Multiply Strings 字符串相乘

Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.这个题说数可能是任意的大的非负数,肯定不是让你直接乘起来返回(我干了。。)而是

2014-09-30 05:47:08 2012

原创 [LeetCode] Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2014-09-30 03:04:51 1110

原创 [LeetCode]Swap Nodes in Pairs 成对交换

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y

2014-09-29 00:08:52 829

原创 [Android Wear]安卓穿戴设备Moto 360测评与开发分析

前言:昨天刚买到了Moto 360,这是楼主目前为止见到的最好的安卓可穿戴设备,一个圆形的手表:BesBuy和官网都卖光了。。这是楼主听说补货了去bestbuy买到的。外形上这就是一块普通的电子表,但其实包含的功能确实不少。最令人心动的就是它圆形的表盘,这比市面上方形的安卓手表更具有吸引力。唯一的遗憾就是。。不是完整的圆形(处女座的。。) 这个其实是可以理解的:做成完整的圆形也是可

2014-09-28 11:22:16 2009 1

原创 [LeetCode] Palindrome Partitioning II

public int minCut(String s) { int len=s.length(); int[] dp= new int[len]; for(int i=0;i<len;i++){ dp[i]=i; } boolean[][] isPalin=new boolean[len][le

2014-09-26 12:08:16 500

原创 [LeetCode] Palindrome Partitioning I

Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","

2014-09-26 12:05:06 601

原创 [LeetCode] Valid Palindrome

public boolean isPalindrome(String s) { if(s==null) return false; s=s.toLowerCase(); StringBuilder sb= new StringBuilder(); for(int i=0;i<s.length();i++){ c

2014-09-26 09:54:03 674

原创 [LeetCode] Candy

public int candy(int[] ratings) { int n=ratings.length; int[] c= new int[n]; Arrays.fill(c,1); for(int i=0;i<n-1;i++){ if(ratings[i]>ratings[i+1] && c[i]<=c

2014-09-25 23:15:52 518

原创 [LeetCode] Word Break II

public List wordBreak(String s, Set dict) { int n=s.length(); boolean[] dp=new boolean[n+1]; dp[0]=true; List> words = new ArrayList>(); for (int i = 0; i <= n; i++)

2014-09-25 14:29:11 564

原创 [LeetCode]Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the to

2014-09-25 14:22:24 644

原创 [LeetCode]Maximum Product Subarray 新题152 最大乘积子序列

public int maxProduct(int[] A) { int n=A.length; if (n==0) return 0; int max = 1, min = 1; int res = Integer.MIN_VALUE; for (int i=0;i<n;i+

2014-09-25 05:52:16 879 2

原创 [LeetCode]Maximum Subarray

Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.

2014-09-25 05:38:09 598

原创 [LeetCode] World Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"

2014-09-24 23:42:17 785

原创 [LeetCode] Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe

2014-09-23 03:59:04 584

原创 安卓点滴01

今天新入手一台安卓设备调试程序,结果把发现以前好用的程序装上报错了:

2014-09-23 00:10:52 799

原创 [LeetCode]Sort List 链表排序 + Merge Two Sorted List 合并两个有序链表

Sort a linked list in O(n log n) time using constant space complexity.先不管zen

2014-09-22 01:01:04 824

原创 [LeetCode]Convert Sorted Array to Binary Search Tree 将有序数组转换成BST

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.public class Solution { public TreeNode sortedArrayToBST(int[] num) { if(num.length

2014-08-09 03:04:59 638

原创 [LeetCode]Balanced Binary Tree 新理解

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2014-08-09 02:48:55 541

原创 [LeetCode]Merge K sorted List合并K个有序链表

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

2014-08-08 22:28:09 879

原创 [LeetCode]Clone Graph 克隆图

lone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for eac

2014-08-04 23:56:49 1754 1

原创 [leetcode]Reverse Nodes in k-Group 反转以k个节点为一组的链表

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is

2014-08-04 07:22:12 865

原创 [LeetCode]Valid Number有效数字

public boolean isNumber(String s) { if (s == null) return false; int start = 0, end = s.length() - 1; while (start <= end && s.charAt(start) == ' ') { start++; } while (end >= sta

2014-07-25 09:23:09 1245

转载 Eclipse 快捷键(windows)mac版把ctrl换成commend即可

Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+↑ 复制当前行到上一行(复制增加)Alt+↓ 当前行和下面一行交互位置(特别实用,可以省去先剪切,再粘贴了)Alt+↑ 当前行和上面一行交互位置(同上)Alt+← 前一个编辑的页面Alt+→ 下一个编辑的页面(当然是针对

2014-06-04 04:16:30 2513

原创 [android] 每次新建项目出现appcompat_v7 解决方法

更新ADT至22.6.0版本之后,创建新的安装项目,会出现appcompat_v7的一个项目,挺不适应的。 后来就出现了一堆 appcompat_v7,然后我就全删了,之后创建的项目全是各种错误,一晚上就搞了个这,疯了。后来发现只要创建的时候把minimum API 从8改为14就好了!太坑爹了!

2014-04-02 14:51:55 2236

原创 [LeetCode]Permutation I排列

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].高中数学就学过了排列(Pe

2014-03-27 04:53:09 622

原创 [leetcode]Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2014-03-23 02:19:44 630

原创 [leetcode]Minimum Path Sum 最小路径和

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2014-03-12 10:11:26 512

原创 [leetcode]Combination组合

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]

2014-03-12 09:45:23 523

原创 [LeetCode]Triangle三角形

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [

2014-03-10 13:02:38 642

原创 [LeetCode]Reverse Words in a String 新题151

Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".这个题不难,结果我做的时候出现了TIME LIMIT EXCEED之前是用栈做的,把每个单词push进去,pop出来,就是倒序了么,感觉

2014-03-08 13:50:43 1138

原创 [LeetCode]Next Permutation

mplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible

2014-03-05 12:00:45 575

原创 [leetcode]Convert Sorted Array to Balanced Binary Search Tree (BST)

这是面试题中比较基础的,但是又对于数据结构有帮助的题。分析:构建二叉树,那么第一个应该想到的是,根节点就是数组中间的节点,根节点的左孩子是mid-1,右孩子是mid+1那么如何对应到整个数组上呢,第二个想到,应该用递归,递归是比较符合树的逻辑的。那么一种思路是: 根的左节点把左半部分 [0,mid-1] ,调用自己,递归下去右边是[mid+1,end] ,这样左边一层一层的就到

2014-02-25 07:51:56 621

原创 [leetcode]Convert Sorted List to Binary Search Tree

o(nlogn)public class Solution { public TreeNode sortedListToBST(ListNode head) { // Start typing your Java solution below // DO NOT write main() function if(head == n

2014-02-25 04:44:11 648

原创 [面试题]Amazon: Given two binary trees,if the first tree is subtree of the second one

Given two binary trees, check if the first tree is subtree of the second one. A subtree of a tree T is a tree S consisting of a node in T and all of its descendants in T. The subtree corresponding t

2014-02-11 11:19:14 927

原创 [LeetCode]String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca

2014-01-28 21:52:44 614

空空如也

空空如也

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

TA关注的人

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