The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of …
HDU 1087 [Super Jumping! Jumping! Jumping!]动态规划
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087 题目大意:有N个格子,每个格子有数值。从原点开始跳,可以跳到任何一个位置;在某一个位置,只能跳到右边数值比它大的位置…
剑指offer三从头到尾打印链表
一、题目: 输入一个链表,从尾到头打印链表每个节点的值。 二、解题方法: 方法一:采用递归的方式实现 方法二:借助堆栈的“后进先出”实现 import jav…
[array] leetcode - 34. Search for a Range - Medium
leetcode – 34. Search for a Range – Medium descrition Given an array of integers sorted in ascendi…
[LeetCode] Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations:add and find. add ̵…
[LeetCode] Reverse Words in a String II 翻转字符串中的单词之二
Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s…
[LeetCode] Equal Tree Partition 划分等价树
Given a binary tree with n nodes, your task is to check if it’s possible to partition t…
[LeetCode] Binary Search 二分搜索法
Given a sorted (in ascending order) integer array nums of n elements and …
利用构造函数求1到n的和 46
class ConSum{ private: static int n; static int sum; public: ConSum(){++n;sum+n} static int getSum(){return su…
常见的链表排序(Java版)
上篇博客中讲解了九大内部排序算法,部分算法还提供了代码实现,但是那些代码实现都是基于数组进行排序的,本篇博客就以链表排序实现几种常见的排序算法,以飨读者。  …
优先队列(priority_queue)的C语言实现(转)
优先队列(priority_queue)的C语言实现 优先队…
【数据结构】红黑树的插入(Insert)
前言: 红黑树是一棵二叉搜索树,它在每个节点上增加了一个存储位来表示节点的颜色,可以是Red或Black。通过对任何一条从根到叶子简单路径上的颜色来约束,红黑树保证最长路径不超过最短路径的两倍,…