自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode 55. Jump Game&&LeetCode 45. Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you ...

2020-01-22 18:33:53 121

原创 AVL树的简单实现

#include<cstdio>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>using namespace std;class AVLNode{public: int data; int height; AVLNode *l...

2020-01-17 18:16:26 277

原创 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.For example, givenpreorder = [3,9,20,15,7]inorder = [9,3,15,...

2019-12-10 22:28:30 98

原创 LeetCode 101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric:1/ 2 2/ \ / 3 4 4 3But the followin...

2019-12-10 22:25:19 92

原创 LeetCode 145. Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes’ values.Example:Input: [1,null,2,3]12/3Output: [3,2,1]Follow up: Recursive solution is trivial, could you do it iteratively?给...

2019-12-09 20:12:27 63

原创 LeetCode 104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children....

2019-12-09 20:11:09 121

原创 LeetCode 456. 132 Pattern

Given a sequence of n integers a1, a2, …, an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input an...

2019-12-08 16:58:42 78

原创 LeetCode 239. Sliding Window Maximum

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window m...

2019-12-07 17:32:06 69

原创 LeetCode 475. Heaters

Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.Now, you are given positions of houses and heaters on a horizontal lin...

2019-12-07 17:25:37 84

原创 AcWing 42. 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.The above elevation map is represented by array ...

2019-12-06 22:27:48 65

原创 LeetCode 42. Trapping Rain Water

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.T...

2019-12-06 22:23:41 66

原创 LeetCode 155. 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 ...

2019-12-05 23:01:07 61

原创 LeetCode 162. Find Peak Element

A peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multiple peaks, i...

2019-12-05 22:58:46 75

原创 LeetCode 240. Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each c...

2019-12-04 21:08:04 66

原创 LeetCode 74. Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row i...

2019-12-03 20:48:08 65

原创 LeetCode 148. Sort List

Sort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1->0-&...

2019-12-03 20:06:53 70

原创 LeetCode 142. Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-in...

2019-12-02 17:00:31 65

原创 LeetCode 147. Insertion Sort List

Sort a linked list using insertion sort.A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration one element ...

2019-12-01 21:29:12 72

原创 LeetCode 34. Find First and Last Position of Element in Sorted Array

Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the t...

2019-12-01 13:01:51 77

原创 LeetCode 160. Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Input: intersectV...

2019-11-30 23:09:04 74

原创 LeetCode 21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-&gt...

2019-11-30 23:03:57 58

原创 LeetCode 143. Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You may not modify the values in the list’s nodes, only nodes itself may be changed.Example 1:Given 1->2->...

2019-11-29 23:21:26 66

原创 LeetCode 61. Rotate List

Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplanati...

2019-11-29 23:18:03 59

原创 LeetCode 92. Reverse Linked List II

Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5->...

2019-11-28 22:41:44 59

原创 LeetCode 206. Reverse Linked List

Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursively. ...

2019-11-28 22:02:17 55

原创 LeetCode 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no children....

2019-11-27 22:31:37 72

原创 LeetCode 83. Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output: 1->2-&...

2019-11-27 20:06:41 56

原创 LeetCode 19. Remove Nth Node From End of List

Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the l...

2019-11-27 20:02:58 96

原创 AcWing 415. 栈

栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表。栈有两种最重要的操作,即pop(从栈顶弹出一个元素)和push(将一个元素进栈)。栈的重要性不言自明,任何一门数据结构的课程都会介绍栈。宁宁同学在复习栈的基本概念时,想到了一个书上没有讲过的问题,而他自己无法给出答案,所以需要你的帮忙。宁宁考虑的是这样一个问题:一个操作数序列,从1,2,一直到n,栈A的深度大于...

2019-10-26 22:52:00 104

原创 poj 2376 Cleaning Shifts

DescriptionFarmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divid...

2019-10-20 22:31:02 78

原创 二元多项式

Problem Description给你多个二元多项式和一个操作符,让你输出操作符操作这些二元多项式之后的结果。Input首先输入二元多项式的个数n和操作符号(‘+’,‘*’);后面n行输入每一个多项式。多组输入,当n=0的时候结束输入。(n<5,二元多项式的长度小于1000,二元多项式都是由x,y,^,数字,’+’组成的)Output输出操作之后的结果。(输出的顺序按照...

2019-08-14 23:15:01 962

转载 STL栈与队列的操作

转自作者:长相忆兮长相忆原文:https://blog.csdn.net/hero_myself/article/details/52312644所谓的deque是”double ended queue”的缩写,双端队列不论在尾部或头部插入元素,都十分迅速。而在中间插入元素则会比较费时,因为必须移动中间其他的元素。双端队列是一种随机访问的数据类型,提供了在序列两端快速插入和删除操作的功能,它可...

2019-07-24 20:13:53 112

原创 多项式求和

Problem Description多项式描述如下:1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 ……先请你求出多项式前n项的和。Input第一行输入一个数T代表测试数据个数(T<=1000)。接下来T行每行1个数代表n(0<=n< 2^31)。Output对于每个输入样例,输出多项式和的结果(结果精确到小数点后两位)。每行输出一个结果。Sam...

2019-07-22 20:41:15 406

转载 线性数据结构

数据结构——线性结构总结线性数据结构数组链表栈队列线性数据结构的特征(在数据元素的非空有限集中)数据结构中有且只有一个首元素和尾元素数据结构中的中间元素只有一个前驱和后继同理首元素和尾元素只有一个后继和前驱数据元素的存储(顺序存储和链式存储)和数据元素的操作(插入和删除)是数据结构的重要部分。数据结构中的线性结构可分为线性表,栈和队列。对于这三种结构,有...

2019-07-19 20:31:23 428

原创 合并果子(贪心)

题目描述在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。多多决定把所有的果子合成一堆。每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和。可以看出,所有的果子经过 n-1n−1 次合并之后, 就只剩下一堆了。多多在合并果子时总共消耗的体力等于每次合并所耗体力之和。因为还要花大力气把这些果子搬回家,所以多多在合并果子时要尽可能地节省体力。...

2019-05-18 13:03:05 902

原创 Crack Mathmen e 题(相对简单)山东省第二届ACM大学生程序设计竞赛

Problem DescriptionSince mathmen take security very seriously, they communicate in encrypted messages. They cipher their texts in this way: for every characther c in the message, they replace c with ...

2019-04-28 21:26:06 145

原创 Identifiers(比较简单的题目)山东省第二届ACM大学生程序设计竞赛

Problem DescriptionIdentifier is an important concept in the C programming language. Identifiers provide names for several language elements, such as functions, variables, labels, etc.An identifier ...

2019-04-28 21:23:28 162

原创 Binomial Coeffcients山东省第二届acmD

Sample Input31 110 2954 723Sample Output1453557658这个问题主要考虑的是组合数的应用c[i][j]=c[i-1][j-1]+c[i-1][j];c[i][i]=c[i][0]=1;c[i][1]=i;#include<cstdio>using namespace std;int a[1001][1001]...

2019-04-27 20:22:50 116

原创 对于 kmp的理解 基于poj题目

poj 3461、poj 2752、poj 2406、poj1961Oulipo poj3461The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo group. A quote f...

2019-04-22 21:23:14 182

原创 Oulipo poj3461

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo group. A quote from the book:Tout avait Pair normal, mais tout s’a...

2019-04-22 16:05:12 173

空空如也

空空如也

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

TA关注的人

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