基础不牢,地动山摇!

LeetCode206:Reverse Linked List

Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either iteratively or recursively. Could you implement ...

2015-07-30 11:22:27

阅读数:1707

评论数:0

LeetCode222:Count Complete Tree Nodes

Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level...

2015-07-29 17:17:00

阅读数:1063

评论数:0

LeetCode229:Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) spac...

2015-07-29 15:13:11

阅读数:1187

评论数:0

LeetCode230:Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note:  You may assume k is always valid, 1 ≤ k...

2015-07-29 11:16:55

阅读数:554

评论数:0

LeetCode231:Power of Two

Given an integer, write a function to determine if it is a power of two. Credits: Special thanks to @jianchao.li.fighter for adding this problem an...

2015-07-29 10:14:21

阅读数:788

评论数:1

赫夫曼(Huffman树

转载自:http://blog.163.com/zhoumhan_0351/blog/static/3995422720098275836215/ 一、基本概念 1、赫夫曼(Huffman)树又称最优二叉树或最优搜索树,是一种带权路径长度最短的二叉树。在许多应用中,常常赋给树中结点一个有某种意...

2015-07-28 10:38:33

阅读数:482

评论数:0

四叉树与八叉树

转载自:http://blog.csdn.net/zhanxinhang/article/details/6706217 前序 四叉树或四元树也被称为Q树(Q-Tree)。四叉树广泛应用于图像处理、空间数据索引、2D中的快速碰撞检测、存储稀疏数据等,而八叉树(Octree)主要应用...

2015-07-28 10:07:02

阅读数:471

评论数:0

LeetCode236:Lowest Common Ancestor of a Binary Tree

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The l...

2015-07-27 15:57:21

阅读数:512

评论数:0

LeetCode234:Palindrome Linked List

Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 给定一个单链表,判断它的元素是否是回文。要求在...

2015-07-27 15:47:28

阅读数:699

评论数:0

LeetCode235:Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikip...

2015-07-24 16:18:04

阅读数:545

评论数:0

LeetCode203:Remove Linked List Elements

Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, v...

2015-07-24 15:46:17

阅读数:1257

评论数:0

LeetCode237:Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -...

2015-07-24 15:22:47

阅读数:613

评论数:0

LeetCode227:Basic Calculator II

Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators a...

2015-07-20 16:48:00

阅读数:806

评论数:0

LeetCode11:Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two ...

2015-07-20 16:46:46

阅读数:1197

评论数:0

LeetCode42:Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining...

2015-07-20 16:22:02

阅读数:571

评论数:0

LeetCode238:Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements ofnums ...

2015-07-20 15:56:13

阅读数:768

评论数:0

LeetCode224:Basic Calculator

Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or...

2015-07-15 16:04:08

阅读数:731

评论数:0

LeetCode173:Binary Search Tree Iterator

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the n...

2015-07-14 16:14:09

阅读数:535

评论数:0

最大堆及其操作函数

前几天在做Kth Largest Element in an Array 时使用到了堆,通过那倒题目也了解到了堆的make_heap,push_heap,pop_heap操作,看了C++ reference中的讲解也明白了heap_sort是什么回事。于是想着自己实现以下这四个函数。 堆的定义:...

2015-07-14 15:44:25

阅读数:1007

评论数:0

LeetCode145:Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [3,2,1].Note: Recursive...

2015-07-14 11:21:42

阅读数:588

评论数:0

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