HF_Cherish

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2015年6月24日

摘要: 1. Question判断一个二叉树是否是对称的。Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree i... 阅读全文
posted @ 2015-06-24 22:08 HF_Cherish 阅读(163) 评论(0) 推荐(0) 编辑

摘要: 1. Question给定两个二叉树,判断是不是相同(结构相同,值相同)的树。Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equa... 阅读全文
posted @ 2015-06-24 22:00 HF_Cherish 阅读(144) 评论(0) 推荐(0) 编辑

摘要: 1. Question给定有序链表,删除重复的,使每个元素仅出现一次。2. Solution(O(n))相似的有Remove Duplicates from Sorted Array,remove element/** * Definition for singly-linked list. * p... 阅读全文
posted @ 2015-06-24 21:55 HF_Cherish 阅读(151) 评论(0) 推荐(0) 编辑

摘要: 1. Questionn级台阶,每次可以走一级或两级,问有多少种走法。You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In... 阅读全文
posted @ 2015-06-24 21:51 HF_Cherish 阅读(128) 评论(0) 推荐(0) 编辑

摘要: 1. Question给定一个非负数,用数组存储其各数位,对这个数加一,返回结果。数组中,最高位在数组头。Given a non-negative number represented as an array of digits, plus one to the number.The digits ... 阅读全文
posted @ 2015-06-24 21:26 HF_Cherish 阅读(178) 评论(0) 推荐(0) 编辑

摘要: 1. Question给定数组和一个值,去掉该数组中的这个值,返回新数组长度。要求操作是in place的,返回的数组元素位置可变,新数组之后的部分无所谓。Given an array and a value, remove all instances of that value in place ... 阅读全文
posted @ 2015-06-24 21:24 HF_Cherish 阅读(161) 评论(0) 推荐(0) 编辑

摘要: 1. Question给定有序数组,去掉其中的重复元素,使得每个元素仅出现一次。要求实现是in place的,即仅能使用常数级的的额外空间。要求返回新数组的长度,同时原数组的该长度内是要求的数,该长度以后的数组内容无所谓。Given a sorted array, remove the duplic... 阅读全文
posted @ 2015-06-24 21:17 HF_Cherish 阅读(235) 评论(0) 推荐(0) 编辑

摘要: 1. Question合并两个有序链表,返回的新链表是通过拼接原来的两个链表得到Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together th... 阅读全文
posted @ 2015-06-24 21:02 HF_Cherish 阅读(157) 评论(0) 推荐(0) 编辑

摘要: 1. Question给一个整型数组,找所有唯一的和为0的三个数的数对。相似的题有2SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique ... 阅读全文
posted @ 2015-06-24 11:28 HF_Cherish 阅读(230) 评论(0) 推荐(0) 编辑

2015年6月23日

摘要: 1. Question找字符串数组的最长公共前缀,是所有字符串的。Write a function to find the longest common prefix string amongst an array of strings.2. Solution(O(mn))以第一个字符串作为前缀初值... 阅读全文
posted @ 2015-06-23 23:00 HF_Cherish 阅读(141) 评论(0) 推荐(0) 编辑