- 博客(10)
- 收藏
- 关注
原创 数据结构(java)----MyArrayList
最近看的书叫“数据结构与算法分析,java语言描述”,里面有讲到各种数据结构的实现。今天先写出最简单的一部分,ArrayList的实现
2016-07-16 22:48:54 182
原创 最大的矩形
问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi。这n个矩形构成了一个直方图。例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2, 3。 输入格式 请找出能放在给定直方图里面积最大的矩形,它的边要与坐标轴平行。对于上面给出的例子,最大矩形如下图所示的阴影部分,面积是10。 第一行包含一个整数n,即矩形的数量(1 ≤ n ≤
2016-07-16 22:05:30 248
原创 ISBN号码
问题描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字、1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如0代表英语;第一个分隔符“-”之后的三位数字代表出版社,例如670代表维京出版社;第二个分
2016-07-16 21:51:47 344
原创 出现次数最多的数
问题描述 给定n个正整数,找出它们中出现次数最多的数。如果这样的数有多个,请输出其中最小的一个。 输入格式 输入的第一行只有一个正整数n(1 ≤ n ≤ 1000),表示数字的个数。 输入的第二行有n个整数s1, s2, …, sn (1 ≤ si ≤ 10000, 1 ≤ i ≤ n)。相邻的数用空格分隔。 输出格式 输出这n个次数中出现次数最多的数。如果这样的数有多个,输出其中最小的
2016-07-16 21:47:16 248
原创 Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements
2016-07-14 22:44:46 223
原创 Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.
2016-07-14 22:37:49 137
原创 Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to4 / \ 7 2 / \ / \ 9 6 3 1
2016-07-14 22:34:50 233
原创 Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. The result can be in
2016-07-14 22:29:04 172
原创 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Subscribe to see which companies asked this
2016-07-13 20:29:37 168
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人