- 博客(13)
- 资源 (33)
- 问答 (1)
- 收藏
- 关注
原创 二叉树前序、中序、后序遍历(Java递归版)
Binary Tree Preorder Traversalpublic class Solution { public List preorderTraversal(TreeNode root) { List result = new ArrayList(); helper(root, result); return result;
2016-09-30 18:42:25 698
原创 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 possibl
2016-09-29 21:28:31 480
转载 栈的压入、弹出序列
http://www.nowcoder.com/questionTerminal/d77d11405cc7470d82554cb392585106栈的压入、弹出序列题目描述输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5
2016-09-14 19:40:06 532
转载 把数组排成最小的数
把数组排成最小的数http://www.nowcoder.com/questionTerminal/8fecd3f8ba334add803bf2a06af1b993题目描述输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。
2016-09-14 13:25:04 433
原创 把二叉树打印成多行 按之字形顺序打印二叉树 binary tree zigzag level order traversal
把二叉树打印成多行题目描述从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。import java.util.*;/*public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public Tree
2016-09-12 21:02:45 968
原创 从尾到头打印链表 反转链表
从尾到头打印链表题目描述输入一个链表,从尾到头打印链表每个节点的值。 输入描述:输入为链表的表头输出描述:输出为需要打印的“新链表”的表头/*** public class ListNode {* int val;* ListNode next = null;**
2016-09-12 13:47:32 531
原创 华为OJ-质数因子-C++实现/Java实现
质数因子题目描述功能:输入一个正整数,按照从小到大的顺序输出它的所有质数的因子(如180的质数因子为2 2 3 3 5 )最后一个数后面也要有空格详细描述:函数接口说明:public String getResult(long ulDataInput)输入参数:long ulDataInput:输入的正整数返回值:String输入描述:输入一个long型整数输出描述:按照从小到大的顺序输出它的所有...
2016-09-11 13:42:58 929
原创 3Sum
3sum温赵菊苣做过的题题目描述Given an array S of n integers, are there elements a, b, c in S such that a + b + c= 0? Find all unique triplets in the array which gives the sum of zero.
2016-09-11 12:08:33 358
原创 最大差值 贪心
最大差值题目描述有一个长为n的数组A,求满足0≤a≤b给定数组A及它的大小n,请返回最大差值。测试样例:[10,5],2返回:0import java.util.*;public class LongestDistance { public int getDis(int[] A, int n) { //
2016-09-11 11:22:28 1026
原创 LeetCode:152. Maximum Product Subarray Java 子数组最大乘积
152. Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contigu
2016-09-05 13:52:56 1250
原创 LeetCode:234. Palindrome Linked List 回文链表 Java
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?Subscribe to see which companies asked this question回文链表
2016-09-04 13:25:18 930 1
原创 maximum-subarray Java 贪心
题目描述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,−5,4],the contiguous subarra
2016-09-03 14:27:38 995
原创 最长公共子串 最长公共子序列
经典动态规划问题最长公共子串(要求连续)最长公共子串题目描述对于两个字符串,请设计一个时间复杂度为O(m*n)的算法(这里的m和n为两串的长度),求出两串的最长公共子串的长度。这里的最长公共子串的定义为两个序列U1,U2,..Un和V1,V2,...Vn,其中Ui + 1 == Ui+1,Vi + 1 == Vi+1,同时Ui == Vi
2016-09-03 13:40:21 1886
《第一行代码》之后有什么推荐书籍吗?比如《Android开发艺术探索》之类的?
2016-05-12
TA创建的收藏夹 TA关注的收藏夹
TA关注的人