自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

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

原创 求 数组里 和为s的所有组合

求 数组里 和为s的所有组合 关键在于去重,但是去重的方式也很简单。 public ArrayList> combinationSum(int[] candidates, int target) { if (candidates == null) return null; Arrays.sort(candidates); boolean[] used = ne

2013-09-15 22:13:53 1360

原创 求直方图里的最大面积

import java.util.Arrays; import java.util.Scanner; /** * @Title: Longest_Up.java * @Package * @Description: TODO * @author nutc * @date 2013-9-8 下午7:16:34 * @version V1.0 */ public class Longe

2013-09-09 15:06:29 720

原创 Search for a Range leetcode

Search for a Range Mar 3 '12 5829 / 15540 Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order

2013-09-08 13:50:27 594

原创 除数

两个数字相除 不能用 除号等 /** * @Title: temp.java * @Package * @Description: TODO * @author nutc * @date 2013-9-7 下午1:42:09 * @version V1.0 */ public class temp { public static void main(String

2013-09-07 14:29:24 793

原创 求出所有组合

public class Solution { public ArrayList> subsets(int[] S) { ArrayList list = new ArrayList(); sub(S,0,list); return all; } static ArrayList> all = new ArrayLi

2013-09-06 15:53:56 611

原创 1.1 Sort Colors 单词遍历 给0,1,2排序 leetcode

1.1      Sort Colors  单词遍历 给0,1,2排序 Given an array with n objectscolored red, white or blue, sort them so that objects of the same color areadjacent, with the colors in the order red, white and blu

2013-09-06 15:09:45 1086

原创 Set Matrix Zeroes leetcode

Set Matrix Zeroes Apr 6 '12 4561 / 10629 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space? A straight forward solu

2013-09-06 14:02:46 790

原创 Text Justification leetcode

Text Justification Apr 3 '12 3100 / 15986 Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should

2013-09-06 10:13:31 735

原创 Add Binary leetcode

Add Binary Apr 2 '12 5763 / 16556 Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 我的丑陋的public class Solution { public Strin

2013-09-03 16:23:00 668

原创 Distinct Subsequences 不同子序列

Distinct Subsequences Oct 19 '12 6266 / 17972 Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from

2013-09-01 21:51:59 837

原创 Convert Sorted List to Binary Search Tree

Convert Sorted List to Binary Search Tree Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. package Tree; /** * @Title: Conver

2013-09-01 15:14:28 744

原创 Flatten Binary Tree to Linked List

Flatten Binary Tree to Linked List Oct 14 '12 7105 / 21371 Given a binary tree, flatten it to a linked list in-place. For example, Given          1         / \        2   5       / \   \   

2013-09-01 14:31:29 638

原创 Populating Next Right Pointers in Each Node

Populating Next Right Pointers in Each Node II Oct 28 '12 5299 / 13177 Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would y

2013-09-01 11:09:52 600

原创 Best Time to Buy and Sell Stock leetcode

LeetCode题目:Best Time to Buy and Sell Stock II   By uniEagle | 2012 年 12 月 4 日 - 16:33 | C++, Develop, 算法 这个更简单了,题目要求可以多次买卖,但是同一时间只能有一股在手里。 这样就可以在每次上升子序列之前买入,在上升子序列结束的时候卖出。相当于能够获得所有的上升子序列的

2013-09-01 10:15:40 1231

原创 Word Ladder leetcode

Word Ladder Feb 11 10499 / 37276 Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be chan

2013-08-29 10:52:33 705

原创 leetcode Longest Common Prefix

Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. package String; import java.util.HashMap; import java.util.Iterator; impor

2013-08-28 22:30:19 819

原创 数组的最长递增 子序列

package Array; import java.util.Arrays; /** * @Title: LongestIncrease.java * @Package Array * @Description: TODO * @author nutc * @date 2013-8-28 下午2:28:11 * @version V1.0 */ public cl

2013-08-28 15:00:29 662

原创 Container With Most Water leetcode

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). F

2013-08-28 13:23:05 663

原创 数字 是否是回文

import String.atoi; /** * @Title: huiwen_num.java * @Package * @Description: TODO * @author nutc * @date 2013-8-28 上午11:02:04 * @version V1.0 */ public class huiwen_num { public static void

2013-08-28 11:35:43 681

原创 atoi 字符串 转换为 数字 leetcode

package String; /** * @Title: atoi.java * @Package String * @Description: TODO * @author nutc * @date 2013-8-28 上午10:33:33 * @version V1.0 */ public class atoi { public static void mai

2013-08-28 10:51:30 699

原创 数字逆序 leetcode

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if

2013-08-28 10:27:16 754

原创 Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if

2013-08-28 10:19:43 684

原创 ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P   A   H   N A P L S I I

2013-08-28 10:05:14 592

原创 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2013-08-27 22:42:43 594

原创 最长 回文子串

n^2的方法 package String; /** * @Title: Longest_Palindromic_Substring.java * @Package String * @Description: TODO * @author nutc * @date 2013-8-27 下午8:31:39 * @version V1.0 */ public class Longe

2013-08-27 22:42:05 579

原创 用链表表示 数字 ,求和 leetcode cc

package Link; import java.util.ArrayList; import java.util.Scanner; /** * @Title: LinkedList_AddSum.java * @Package Link * @Description: You have two numbers represented by a linked list, where e

2013-08-27 20:13:07 1002

原创 leetcode 求两个排序数组的中位数

好复杂的二分思路。。。。 public static double findMedianSortedArrays(int[] A, int[] B) { if (A == null && B == null) return -1; // if (A == null || A.length == 0) //不可,另一个 可能是偶数个 // return B[B.length /

2013-08-27 20:05:14 1328

原创 leetcode 2 sum 3sum 4sum

Two SumMar 14 '1115259 / 48327 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

2013-08-27 09:05:09 2969

原创 题目1531:货币面值 (wa)

题目1531:货币面值 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:336 解决:122 题目描述: 小虎是游戏中的一个国王,在他管理的国家中发行了很多不同面额的纸币,用这些纸币进行任意的组合可以在游戏中购买各种装备来提升自己。有一天,他突然很想知道这些纸币的组合不能表示的最小面额是多少,请聪明的你来帮助小虎来解决这个财政问

2013-08-25 21:13:43 894

原创 数组分割问题 编程之美2.18

1.1      【【【思路】】】数组分割问题 题目: 两个序列大小均为n,序列元素的值为任一整数,无序; 要求通过交换两个序列的元素,使序列a元素之和与序列b的元素之和的差最小(可能存在很多种组合,要求找出其中一种即可)。 如序列:1  5   7   8   9和序列6  3   11  20  17我们可以通过交换得到新的序列1  5   9   8  20和序列7   6   3 

2013-08-25 21:02:16 738

原创 编程之美3.3--计算字符串的相似度

问题描述: 把两个字符串变成相同的字符串,具体的操作方法为: 1.     修改一个字符(如把 a 变成 b) 2.     增加一个字符 (如 abed 变成 abedd) 3.     删除一个字符(如 jackbllog 变成 jackblog) 针对于 jackbllog到jackblog 只需要删除一个或增加一个 l 就可以把两个字符串变为相同。把这种操

2013-08-25 14:43:10 830

原创 字符串 移位包含

题目: 给定两个字符串S1和S2,要求判断S2能否被S1做循环移位得到的字符串包含。 例如:s1=AABCD和S2=CDAA,返回true, s1=ABCD和s2=ACBD,返回false。 package String; import java.util.Arrays; /** * @Title: if_sub_String_rotate.java * @Packag

2013-08-25 14:16:51 800

原创 编程之美3.2 电话号码对应英语单词

/**       * 编程之美 电话号码对应英语单词       * 题目:       *  手机上的拨号盘,每个数字都对应一些字母,比如2对应ABC,3对应DEF.........,8对应TUV,9对应WXYZ,       *  要求对一段数字,输出其代表的所有可能的字母组合,如5869,可能代表JTMW、JTMX...       *  以下程序用DFS得解,但:      

2013-08-25 14:15:35 1523

原创 题目1214:丑数

题目描述: 把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。 输入: 输入包括一个整数N(1 输出: 可能有多组测试数据,对于每组数据, 输出第N个丑数。 样例输入: 3 样例输出: 3 答疑:

2013-08-22 22:41:12 839

原创 题目1391:顺时针打印矩阵

题目描述: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10. 输入: 输入可能包含多个测试样例,对于每个测试案例, 输入的第一行包括两个整数m和n(1 接下来的m行

2013-08-22 22:32:46 710

原创 题目1515:打印1到最大的N位数

题目描述: 给定一个数字N,打印从1到最大的N位数。 输入: 每个输入文件仅包含一组测试样例。 对于每个测试案例,输入一个数字N(1 输出: 对应每个测试案例,依次打印从1到最大的N位数。 样例输入: 1 样例输出: 1 2 3 4 5 6 7 8 9import java.util.Arrays; impor

2013-08-22 22:23:15 974

原创 题目1504:把数组排成最小的数

题目描述: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。 输入: 输入可能包含多个测试样例。 对于每个测试案例,输入的第一行为一个整数m (1 输入的第二行包括m个正整数,其中每个正整数不超过10000000。 输出

2013-08-22 22:17:32 843

原创 4 4 Given a binary search tree, design an algorithm which creates a linked list of all the nodes at

4 4 Given a binary search tree, design an algorithm which creates a linked list of all thenodes at each depth (eg, if you have a tree with depth D, you’ll have D linked lists)  package Tree; im

2013-08-21 14:45:11 863

原创 题目1509:树中两个结点的最低公共祖先 剑指的40

题目1509:树中两个结点的最低公共祖先 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:203 解决:57 题目描述: 给定一棵树,同时给出树中的两个结点,求它们的最低公共祖先。 输入: 输入可能包含多个测试样例。 对于每个测试案例,输入的第一行为一个数n(0 其中每个测试样例包括两行,第一行为一个

2013-08-20 10:59:25 732

原创 java 大数 操作

a+b import java.util.Arrays; import java.util.Scanner; /** * @Title: Big_Plue.java * @Package * @Description: TODO * @author nutc * @date 2013-8-19 下午10:02:50 * @version V1.0 */ public cl

2013-08-19 22:30:54 616

空空如也

空空如也

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

TA关注的人

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