摘要: 题目: 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-... 阅读全文
posted @ 2015-05-19 00:35 sunp823 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目: Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one... 阅读全文
posted @ 2015-05-18 01:05 sunp823 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 在某个矩阵中,每行元素是递增的,每列元素也是递增的。即a[i][j]15,因此删除第一行,右上方的元素变为19,21>19,删除19所在的第二行,右上方元素变为22,2116,删除16所在的一行,右上方元素变为17,21>17,删除17所在的一行,右上角元素变为26,21#include#def... 阅读全文
posted @ 2015-05-13 01:02 sunp823 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 华为2014校园招聘的机试题目 通过键盘输入一串小写字母(a~z)组成的字符串。请编写一个字符串压缩程序,将字符串中连续出席的重复字母进行压缩,并输出压缩后的字符串。 压缩规则: 1、仅压缩连续重复出现的字符。比如字符串"abcbc"由于无连续重复字符,压缩后的字符串还是"abcbc"。... 阅读全文
posted @ 2015-05-11 23:56 sunp823 阅读(504) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 /... 阅读全文
posted @ 2015-05-11 20:17 sunp823 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. ... 阅读全文
posted @ 2015-05-11 19:33 sunp823 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right a... 阅读全文
posted @ 2015-05-07 00:26 sunp823 阅读(119) 评论(0) 推荐(0) 编辑
摘要: List接口总结: List接口是Collection接口的子接口,从其名称可以看出,是一个元素有序(并不是按大小排序,具有顺序索引,类似于数组),默认按照元素的添加顺序设置元素的索引,List和Set不同在于List可以具有重复元素,List增加了按照索引插入(add(int index,... 阅读全文
posted @ 2015-05-07 00:16 sunp823 阅读(6708) 评论(0) 推荐(1) 编辑
摘要: C语言结构体的对齐问题 C语言的结构体对齐问题是常见类型的题目,在笔试和面试中也是常考的题目,例如: struct { int a; char b; long c; short d; }s; 问sizeof(s) = ? 我们假设在32位机器下,要解决这个问题我们必须明确... 阅读全文
posted @ 2015-05-04 16:21 sunp823 阅读(1696) 评论(0) 推荐(1) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 ... 阅读全文
posted @ 2015-05-02 21:24 sunp823 阅读(116) 评论(0) 推荐(0) 编辑