参考文章:http://blog.csdn.net/anonymalias/article/details/11020477 链表定义 1 template <typename Type> 2 struct ListNode{ 3 Type data; 4 ListNode *next; 5 };
分类:
编程语言 时间:
2016-03-09 11:05:55
阅读次数:
456
题目:有4个杯子,10包粉末,其中有2包溶于水变蓝,其余无色,粉末溶于水2min才能显现颜色。求找出两包蓝色粉末的最短时间。假设水和粉末用不完。 方法一: 第一趟:[12,34,56,78] 每个杯子分别放两包加水融化,剩下两包不管。可能的情况: (1)0个杯子变色,说明剩下两包就是蓝粉末 (2)1
分类:
编程语言 时间:
2016-02-27 14:59:30
阅读次数:
177
题目:有4个杯子,10包粉末,其中有2包溶于水变蓝,其余无色,粉末溶于水2min才能显现颜色。求找出两包蓝色粉末的最短时间。假设水和粉末用不完。 解:以下给出四种解法,标记10包粉末为(1,2 ... ) 杯子为[1,2,3,4]首先我想会不会是有某种算法,dp 二分。。@~@。。没有,懵懵的。 法
分类:
编程语言 时间:
2016-02-26 20:43:31
阅读次数:
229
一个面试题:java实现将一个int数组变为一个int整数。例如:int[]arr=newint[]{1,2,3,4,5};变为12345/**
*Createdbyleoon15/10/27.
*/
publicclassInterview{
publicstaticvoidmain(String[]args){
System.out.println(parseInt(newint[]{1,2,3,4,5}));
System.out.println(In..
分类:
编程语言 时间:
2015-10-27 13:30:10
阅读次数:
138
【226-Invert Binary Tree(反转二叉树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Invert a binary tree. 4
/ 2 7
/ \ / 1 3 6 9 to 4
/ 7...
分类:
编程语言 时间:
2015-08-30 07:42:46
阅读次数:
187
【219-Contains Duplicate II(包含重复元素II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Given an array of integers and an integer k, find out whether there are two distinct ind...
分类:
编程语言 时间:
2015-08-29 07:30:34
阅读次数:
201
【223-Rectangle Area(矩形区域)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined...
分类:
编程语言 时间:
2015-08-29 07:29:33
阅读次数:
265
【225-Implement Stack using Queues(用队列实现栈操作)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Implement the following operations of a stack using queues.
push(x) – Push ele...
分类:
编程语言 时间:
2015-08-29 07:28:16
阅读次数:
193
【216-Combination Sum III (组合数的和)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find all possible combinations of k numbers that add up to a number n, given that only numbe...
分类:
编程语言 时间:
2015-08-28 07:21:06
阅读次数:
251
【215-Kth Largest Element in an Array(数组中第K大的数)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】代码下载【https://github.com/Wang-Jun-Chao】原题 Find the kth largest element in an unsorted array. Note that it is the kth lar...
分类:
编程语言 时间:
2015-08-28 07:20:26
阅读次数:
368