Ying

个人博客:http://smartsi.club/

[LeetCode]*105.Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.

2015-04-28 21:58:20

阅读数:1470

评论数:0

[经典面试题]位运算操作

[LeetCode]136.Single Numbe[LeetCode]201.Bitwise AND of Numbers Range[剑指Offer]40.数组中只出现一次的数字一道位运算的算法题

2015-04-26 19:42:36

阅读数:1481

评论数:0

[剑指Offer]40.数组中只出现一次的数字

一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。思路我们直到异或的性质:任何一个数字异或他自己都等于0. 所以说我们如果从头到尾依次异或每一个数字,那么最终的结果刚好只出现一次的数字,因为成对出现的两次的数字全部在异或中抵消了。这道题中有两个数字只出现一...

2015-04-26 19:34:17

阅读数:1827

评论数:0

[LeetCode]201.Bitwise AND of Numbers Range

Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the ...

2015-04-26 15:34:55

阅读数:1689

评论数:0

[LeetCode]32.Longest Valid Parentheses

题目Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the ...

2015-04-23 20:18:45

阅读数:1508

评论数:0

[算法系列之三十]Dijkstra单源最短路径算法

单源最短路径问题给定一个带权有向图 G=(V,E) ,其中每条边的权是一个非负实数。另外,还给定 V 中的一个顶点,称为源。现在我们要计算从源到所有其他各顶点的最短路径长度。这里的长度是指路上各边权之和。这个问题通常称为单源最短路径问题。前面Bellman-Ford最短路径算法讲了单源最短路径的B...

2015-04-23 17:30:47

阅读数:2082

评论数:0

[算法系列之二十九]Bellman-Ford最短路径算法

单源最短路径给定一个图,和一个源顶点src,找到从src到其它所有所有顶点的最短路径,图中可能含有负权值的边。Dijksra的算法是一个贪婪算法,时间复杂度是O(VLogV)(使用最小堆)。但是迪杰斯特拉算法在有负权值边的图中不适用,Bellman-Ford适合这样的图。在网络路由中,该算法会被用...

2015-04-23 15:15:27

阅读数:5089

评论数:0

[LeetCode]202.Happy Number

Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive intege...

2015-04-22 21:26:55

阅读数:2247

评论数:0

[LeetCode]57.Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initia...

2015-04-22 15:20:42

阅读数:1265

评论数:0

[LeetCode]191.Number of 1 Bits

题目Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bi...

2015-04-12 19:55:50

阅读数:1172

评论数:0

[经典面试题][去哪网]合并日期

声明一个大小为1001的数组array[1001],全部初始化为0 然后从前向后遍历数组,先处理[0,100,300]再处理[40,50,350]。后面的价格覆盖前面的价格。

2015-04-12 19:44:29

阅读数:1365

评论数:0

[LeetCode]200.Number of Islands

题目Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adja...

2015-04-10 21:27:46

阅读数:1761

评论数:0

[LeetCode]198.House Robber

题目You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping...

2015-04-08 12:16:51

阅读数:2011

评论数:1

[面试经]字节对齐

一、快速理解 什么是字节对齐? 在C语言中,结构是一种复合数据类型,其构成元素既可以是基本数据类型(如int、long、float等)的变量,也可以是一些复合数据类型(如数组、结构、联合等)的数据单元。在结构中,编译器为结构的每个成员按其自然边界(alignment)分配空间。各个成员按照它们被...

2015-04-06 17:04:39

阅读数:1026

评论数:0

[LeetCode]199.Binary Tree Right Side View

题目Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For e...

2015-04-05 21:00:34

阅读数:2172

评论数:0

[程序员面试题精选100题]58.八皇后问题

题目在8×8的国际象棋上摆放八个皇后,使其不能相互攻击,即任意两个皇后不得处在同一行、同一列或者同一对角斜线上。下图中的每个黑色格子表示一个皇后,这就是一种符合条件的摆放方法。请求出总共有多少种摆法。思路这就是有名的八皇后问题。解决这个问题通常需要用递归,而递归对编程能力的要求比较高。因此有不少面...

2015-04-04 22:14:54

阅读数:1383

评论数:0

[LeetCode]4.Median of Two Sorted Arrays

Median of Two Sorted Arrays Total Accepted: 4990 Total Submissions: 30805My Submissions There are two sorted arrays A and B of size m and n respecti...

2015-04-03 11:20:27

阅读数:1317

评论数:0

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