- 博客(55)
- 资源 (39)
- 收藏
- 关注
原创 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 both?使用迭代和递归实现单链表的反转。迭代的方法之间在剑指offer上面
2015-07-30 11:22:27 2128
原创 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, except possibly the last, is completely fille
2015-07-29 17:17:00 1477
原创 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) space.借助于Majority Element中的Boyer Moore算法,可以在O(1)的
2015-07-29 15:13:11 1516
原创 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 ≤ BST's total elements.Follow up:What if the
2015-07-29 11:16:55 662
原创 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 and creating all test cases.这道题有好多种解法。
2015-07-29 10:14:21 950 1
转载 赫夫曼(Huffman树
转载自:http://blog.163.com/zhoumhan_0351/blog/static/3995422720098275836215/一、基本概念1、赫夫曼(Huffman)树又称最优二叉树或最优搜索树,是一种带权路径长度最短的二叉树。在许多应用中,常常赋给树中结点一个有某种意义的实数,称此实数为该结点的权。从树根结点到该结点之间的路径长度与该结点上权的乘积称为结点的带
2015-07-28 10:38:33 730
转载 四叉树与八叉树
转载自:http://blog.csdn.net/zhanxinhang/article/details/6706217前序四叉树或四元树也被称为Q树(Q-Tree)。四叉树广泛应用于图像处理、空间数据索引、2D中的快速碰撞检测、存储稀疏数据等,而八叉树(Octree)主要应用于3D图形处理。对游戏编程,这会很有用。本文着重于对四叉树与八叉树的原理与结构的介绍,帮助您在脑海中建
2015-07-28 10:07:02 898
原创 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 lowest common ancestor is defined between two node
2015-07-27 15:57:21 619
原创 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?给定一个单链表,判断它的元素是否是回文。要求在O(n)的时间复杂度和O(1)的空间复杂度内求解。如果没有时间复杂度的限制,可以直接将链表反转再比较就
2015-07-27 15:47:28 950
原创 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 Wikipedia: “The lowest common ancestor is defined betw
2015-07-24 16:18:04 669
原创 LeetCode203:Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special thanks
2015-07-24 15:46:17 1851
原创 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 -> 3 -> 4 and you are given the third node with val
2015-07-24 15:22:47 734
原创 LeetCode227:Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should trunca
2015-07-20 16:48:00 954
原创 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 endpoints of line i is at (i, ai) and (i, 0). Fin
2015-07-20 16:46:46 1360
原创 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.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]
2015-07-20 16:22:02 716
原创 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 except nums[i].Solve it without division and in O(
2015-07-20 15:56:13 1229
原创 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 minus sign -, non-negative integers and empty space
2015-07-15 16:04:08 925 1
原创 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 next smallest number in the BST.Note: next() and hasN
2015-07-14 16:14:09 663
原创 最大堆及其操作函数
前几天在做Kth Largest Element in an Array 时使用到了堆,通过那倒题目也了解到了堆的make_heap,push_heap,pop_heap操作,看了C++ reference中的讲解也明白了heap_sort是什么回事。于是想着自己实现以下这四个函数。 堆的定义:任意节点小于它的所有后裔,最小元在堆的根上(堆序性)。堆总是一棵完全树。#include <ios
2015-07-14 15:44:25 1242
原创 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 solution is trivial, could you do it iteratively?二叉
2015-07-14 11:21:42 694
原创 LeetCode144:Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [1,2,3].Note: Recursive solution is trivial, could you do it iteratively?先序遍
2015-07-14 10:29:27 633
原创 LeetCode94:Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?二叉树的
2015-07-14 09:56:27 686
转载 二叉树前序遍历非递归写法
转载自:http://blog.csdn.net/zhangxiangdavaid/article/details/37115355前言在前两篇文章二叉树和二叉搜索树中已经涉及到了二叉树的三种遍历。递归写法,只要理解思想,几行代码。可是非递归写法却很不容易。这里特地总结下,透彻解析它们的非递归写法。其中,中序遍历的非递归写法最简单,后序遍历最难。我们的讨论基础是这样的:
2015-07-14 09:36:52 1303
原创 LeetCode49:Anagrams
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case.这道题是题目都没读懂,不知道Anagrams什么意思。Anagrams的意思是那些字符串的组成字符相同。比如说abc,那么abc这三个字符的所有排列都是Anagr
2015-07-14 09:10:45 719
转载 关于C++内存中字节对齐问题的详细介绍
转载自:http://m.jb51.net/article/36903.htm本篇文章是对C++内存中字节对齐的问题进行了详细的分析与总结。需要的朋友参考下一、什么是字节对齐计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定类型变量的时候经常在特定的内存地址访问,这就需要各种类型数据按照一定
2015-07-13 22:52:50 589
原创 LeetCode3:Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. For “
2015-07-13 00:24:28 1028
原创 LeetCode20:Valid Parentheses
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are all valid
2015-07-11 00:02:15 938
原创 LeetCode155:Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the t
2015-07-10 23:32:51 809
原创 LeetCode232:Implement Queue using Stacks
Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue.pop() – Removes the element from in front of queue.peek() – Get the front element.empty() –
2015-07-10 23:08:22 1168
原创 LeetCode225:Implement Stack using Queues
Implement the following operations of a stack using queues.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. empty() – Return whether
2015-07-10 22:46:38 1456
原创 LeetCode215:Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k = 2, return 5.Note:
2015-07-09 21:36:41 2423
原创 LeetCode169:Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always
2015-07-09 19:29:49 2875 1
原创 LeetCode93:Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given “25525511135”, return [“255.255.11.135”, “255.255.111.35”]. (O
2015-07-08 15:50:36 2577 1
原创 LeetCode90:Subsets II
Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate
2015-07-08 11:12:56 1758
原创 LeetCode60:Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):1 “123” 2 “132” 3 “213”
2015-07-08 10:45:24 956
原创 LeetCode131:Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = “aab”, Return [
2015-07-07 17:51:57 2352
原创 LeetCode52:N-Queens II
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. 和N-Queens 同样的解法。class Solution {public: int totalNQueens(int n
2015-07-07 17:02:46 854
原创 LeetCode17:Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit string “2
2015-07-07 16:50:00 912
原创 LeetCode89:Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray
2015-07-07 15:59:59 3001
转载 Catalan数计算及应用
转载自:http://blog.csdn.net/wuzhekai1985/article/details/6764858问题描述:卡塔兰数,是组合数学中一个常出现在各种计数问题中出现的数列。输入一个整数n,计算h(n)。其递归式如下:h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (其中n>=2,h(0) = h(1) = 1)
2015-07-07 14:21:04 619
计算机图形学算法
2014-09-05
TestCameraEye.rar
2014-07-04
GenerateBMP.rar
2014-07-03
PixelColor.rar
2014-07-03
TestPng.rar
2014-07-03
TestCone.rar
2014-07-03
TestCamera
2014-07-03
MFCCompositeViewer.rar
2014-01-06
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人