自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 非递归前序中序后序遍历二叉树

二叉树的遍历问题是二叉树的基本问题,也是在数据结构中比较常见的问题,二叉树的遍历分为前序遍历、中序遍历和后序遍历,其中这些某序指的是每棵子树根节点的位置,对于左右分支来说,顺序永远都是先左后右。我相信学过数据结构的姑娘和小伙子一定对这个都有所了解,并且也都能写出对已知二叉树进行遍历的代码。

2017-05-04 18:07:02 2034 1

原创 滴滴算法工程师实习生一面面经

滴滴今年校招的笔试题灰常的简单,选择是往年的原题,智力题什么的也都可做,两道编程题分别是翻转字符串中单词的字母顺序,和俄罗斯套娃dp问题,于是就接到了找实习以来的第二场现场面试通知。流程基本就是到达滴滴的写字楼然后签到,有一个微信助手排队,有人叫号,面试是一对一的,等了两个小时终于轮到了。。。面试官人很nice,所有面试都在一个大厅里,不过答的不是很好哈哈,之前算法题刷的还算比较多,但

2017-05-04 16:07:04 8628 2

原创 腾讯基础研究一面面经

1、自我介绍2、你的方向是电磁为什么要报这个岗位呢3、说一下这个比赛(2016编程之美挑战赛),你主要是负责什么的4、写一个题吧,给你一个字符串为ip地址,例如“192.0.0.1”,把它转换成一个32位的整数。          一开始没有理解题意,以为是要将四个ip地址的数字拼起来,就问面试官这个整数可能有12个位数,是不是要用longlong存,面

2017-05-04 15:15:15 710

原创 leetcode 273. Integer to English Words

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Thousan

2016-11-30 17:33:42 261

原创 leetcode 144. 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 [1,2,3].# Definition for a binar

2016-11-25 16:14:47 264

原创 leetcode 347. Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].class Solution(object):    def topKFrequent(self, nums, k):

2016-11-25 15:45:28 247

原创 leetcode 409. Longest Palindrome

Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not con

2016-11-25 15:44:13 224

原创 leetcode 392. Is Subsequence

Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) strin

2016-11-25 15:42:21 184

原创 leetcode 167. Two Sum II - Input array is sorted

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two number

2016-11-25 11:40:42 490

原创 leetcode 387. First Unique Character in a String

Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: 

2016-11-24 15:22:10 226

原创 leetcode 383. Ransom Note

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; ot

2016-11-24 11:26:43 215

原创 leetcode 404 Sum of Left Leaves

Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24

2016-11-24 11:25:31 236

原创 leetcode 24 Swap Nodes in Pairs

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 as2->1->4->3.Your algorithm should use only constant s

2016-08-12 10:27:17 215

原创 leetcode 50 Pow(x, n)

Implement pow(x, n).以上就是这道题目的题干,看起来非常简单没有什么过多的要求,实际上也是用最简单的方法做的,但是这道题目需要注意的细节很多,解法如下:最简单的方法可以利用math库函数进行计算class Solution {public:    double myPow(double x, int n)     {        return

2016-08-12 09:03:19 231

原创 leetcode 69 Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.这道题目是写int类型开平方的方法,这题的解法有很多,可以通过遍历来实现,我的方法还是和之前的一道题目相似,用二分查找的方式,这道题目一定还有更简单的方法,先说一下我的算法:class Solution {public:    int mySqrt

2016-08-09 19:58:45 191

原创 leetcode 374 Guess Number Higher or Lower

题目要求:We are playing the Guess Game. The game is as follows:I pick a number from 1 ton. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number

2016-08-05 22:33:25 297

原创 正则表达式学习笔记

^           ——代表一行的开始 ^abc$           ——代表一行的结束 abc$^$         ——空行[…]       ——或 [ab]即a或b-            ——连字符,表示一个范围0-2相当于012[^…]      ——排除,[^12]即排除1和2以外的任意字符.            ——匹配任意字符|      

2016-08-04 09:55:08 285

原创 leetcode41First Missing Positive & hihocoder1040矩形判断(C++)

近期刷了leetcode的41题和hihocode的1040题,在做这两题的时候都用到了数组的方式,只不过作用有些不同。1、leetcode41 First Missing Positive这道题的题目是这样的:Given an unsorted integer array, find the first missing positive integer.For example

2016-08-03 16:14:26 445

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除