- 博客(35)
- 资源 (7)
- 问答 (1)
- 收藏
- 关注
原创 Largest Number 拼凑成最大的数
Largest Number Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Not
2015-05-28 22:21:18 400
原创 Binary Search Tree Iterator 二叉搜索树的遍历
Binary Search Tree Iterator Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next small
2015-05-28 22:19:41 751
原创 Fraction to Recurring Decimal 分数转为小数
Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose
2015-05-28 22:18:31 489
原创 Find Peak Element 寻找最大的数
Find Peak Element A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may c
2015-05-28 11:47:57 506
原创 Find Minimum in Rotated Sorted Array 循环数组中查找最小的数
Find Minimum in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element
2015-05-28 11:45:17 361
原创 Maximum Product Subarray 连续数组的最大乘积
Maximum Product Subarray Find 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 contiguou
2015-05-28 11:44:24 479
原创 Reverse Words in a String 翻转句子的单词
Reverse Words in a String Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programm
2015-05-28 11:43:26 523
原创 Sort List 归并排序链表
Sort List Sort a linked list in O(n log n) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; *
2015-05-28 11:41:52 376
原创 Insertion Sort List 链表的插入排序
Insertion Sort List Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : v
2015-05-28 11:40:26 530
原创 Binary Tree Preorder Traversal 链表的前序遍历
Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return
2015-05-28 11:39:03 391
原创 Reorder List 链表位置的变换 数组处理
Reorder List Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3
2015-05-20 20:56:30 394
原创 Linked List Cycle II 求单链表环的入口
Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?/** * Definiti
2015-05-20 20:54:50 490
原创 Linked List Cycle 判断链表是否有环
Linked List Cycle Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * struct ListNo
2015-05-20 20:54:44 494
原创 Word Break DP字符串查找
Word 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 = "leetcod
2015-05-20 20:49:26 473
原创 hihoCoder 1040 : 矩形判断 计算几何
1040 : 矩形判断时间限制:1000ms单点时限:1000ms内存限制:256MB描述给出平面上4条线段,判断这4条线段是否恰好围成一个面积大于0的矩形。输入输入第一行是一个整数T(1每组数据包含4行,每行包含4个整数x1, y1, x2, y2 (0 输出每组数据输出一行YES或者NO,表示输入的4条线段
2015-05-20 20:43:33 546
原创 hihoCoder 1078 : 线段树的区间修改
#1078 : 线段树的区间修改时间限制:10000ms单点时限:1000ms内存限制:256MB描述对于小Ho表现出的对线段树的理解,小Hi表示挺满意的,但是满意就够了么?于是小Hi将问题改了改,又出给了小Ho:假设货架上从左到右摆放了N种商品,并且依次标号为1到N,其中标号为i的商品的价格为Pi。小Hi的每次操作分为两种可能,第一
2015-05-14 21:01:58 558
原创 hihoCoder 1077 RMQ问题再临-线段树 单点修改,求区间最小值
1077 : RMQ问题再临-线段树时间限制:10000ms单点时限:1000ms内存限制:256MB描述上回说到:小Hi给小Ho出了这样一道问题:假设整个货架上从左到右摆放了N种商品,并且依次标号为1到N,每次小Hi都给出一段区间[L, R],小Ho要做的是选出标号在这个区间内的所有商品重量最轻的一种,并且告诉小Hi这个商品的重量。但是
2015-05-14 20:58:52 745
原创 hihoCoder 1151 : 骨牌覆盖问题·二 矩阵快速幂
#1151 : 骨牌覆盖问题·二时间限制:10000ms单点时限:1000ms内存限制:256MB描述上一周我们研究了2xN的骨牌问题,这一周我们不妨加大一下难度,研究一下3xN的骨牌问题?所以我们的题目是:对于3xN的棋盘,使用1x2的骨牌去覆盖一共有多少种不同的覆盖方法呢?首先我们可以肯定,奇数长度一定是没有办法覆盖的;对于偶
2015-05-14 20:57:00 797
原创 Single Number II 每个数出现3次,求单个数
Single Number II Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you
2015-05-12 17:42:16 412
原创 Single Number 异或求单独数
Single Number Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implemen
2015-05-12 17:40:55 453
原创 hihoCoder 1143 : 骨牌覆盖问题·一 矩阵快速幂
1143 : 骨牌覆盖问题·一时间限制:10000ms单点时限:1000ms内存限制:256MB描述骨牌,一种古老的玩具。今天我们要研究的是骨牌的覆盖问题:我们有一个2xN的长条形棋盘,然后用1x2的骨牌去覆盖整个棋盘。对于这个棋盘,一共有多少种不同的覆盖方法呢?举个例子,对于长度为1到3的棋盘,我们有下面几种覆盖方式:
2015-05-12 17:36:23 729
原创 阿里巴巴2015基础平台研发工程师实习生笔试卷
1 0~999999之间的所有数字中,任何一位都不包括数字1的数字总数为多少999992621443810415242885314419000009的6次方 因为是0-999999 排列组合计算2 以下关于STL的描述中,____是错的。STL容器是线程不安全的当容量不够时,vector内部内存扩展方式是翻倍std::sort是稳定排序s
2015-05-11 22:05:14 1822
原创 Gas Station 汽车加油问题
Gas Station There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to trave
2015-05-11 18:00:28 724
原创 Clone Graph BFS
Clone Graph Clone 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 # a
2015-05-11 17:57:46 451
原创 hihoCoder 1037 : 数字三角形 动态规划
#1037 : 数字三角形时间限制:10000ms单点时限:1000ms内存限制:256MB问题描述小Hi和小Ho在经历了螃蟹先生的任务之后被奖励了一次出国旅游的机会,于是他们来到了大洋彼岸的美国。美国人民的生活非常有意思,经常会有形形色色、奇奇怪怪的活动举办,这不,小Hi和小Ho刚刚下飞机,就赶上了当地的迷宫节活动。迷宫节里展览出来的迷
2015-05-11 17:57:23 472
原创 Palindrome Partitioning DFS
Palindrome Partitioning 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 = "
2015-05-08 22:15:59 441
原创 Surrounded Regions BFS遍历
Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For ex
2015-05-08 22:13:15 416
原创 hihoCoder 1049 : 后序遍历
#1049 : 后序遍历时间限制:10000ms单点时限:1000ms内存限制:256MB描述在参与过了美食节之后,小Hi和小Ho在别的地方又玩耍了一阵子,在这个过程中,小Ho得到了一个非常有意思的玩具——一棵由小球和木棍连接起来的二叉树!小Ho对这棵二叉树爱不释手,于是给它的每一个节点都标记了一个标号——一个属于A..Z的大写字母,
2015-05-08 22:10:53 522
原创 hihoCoder 1066 : 无间道之并查集
1066 : 无间道之并查集时间限制:20000ms单点时限:1000ms内存限制:256MB描述这天天气晴朗、阳光明媚、鸟语花香,空气中弥漫着春天的气息……额,说远了,总之,小Hi和小Ho决定趁着这朗朗春光出去玩。但是刚刚离开居住的宾馆不久,抄近道不小心走入了一条偏僻小道的小Hi和小Ho就发现自己的前方走来了几个彪形大汉,定睛一看还
2015-05-08 22:08:34 547
原创 阿里巴巴2015算法工程师实习生笔试卷
1 用十进制计算30!(30的阶乘),将结果转换成3进制进行表示的话,该进制下的结果末尾会有____个0。6810121416//N/3+N/9+N/27=14 3进制里,只有=3的时候会进位,末尾会是0,而3进制里只有1*3=3,2 小赵和小钱二人分别从寝室和图书馆同时出发,相向而行。过了一段时间后二人在中途相遇,小赵继续向图书馆前进,此时:若小钱继续
2015-05-08 15:08:10 2546
原创 Sum Root to Leaf Numbers 根节点到叶子组成数的和
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 represen
2015-05-07 18:08:30 459
原创 Word Ladder 字符的相似变化
Word Ladder Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be c
2015-05-07 18:07:42 464
原创 Best Time to Buy and Sell Stock II DP买卖股票
Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete a
2015-05-07 18:06:42 432
原创 Best Time to Buy and Sell Stock 买卖
Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, b
2015-05-07 18:05:53 362
原创 Triangle DP求最大和
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]
2015-05-07 18:04:53 521
spring mybatis sql语句使用注解描述
2016-10-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人