自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(15)
  • 收藏
  • 关注

原创 leetcode 题解代码整理 36-40题

Valid Sudoku   Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partia...

2015-08-19 23:01:50 646

原创 leetcode 题解代码整理 31-35题

Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as

2015-08-15 23:44:31 643

原创 leetcode 题解代码整理 26-30题

  Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another...

2015-08-15 14:11:02 478

原创 leetcode 题解代码整理 21-25题

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. 合并两个有序链表

2015-08-14 12:21:05 708

原创 HDU 5389 DP

给出n个人的id,有两个门,每个门有一个标号a个b,现在我们要将n个人分成两组,进入两个门中,使得两部分人的标号的和(迭代的求,直至变成一位数)分别等于a和b,问有多少种分法,也可全进入其中的一扇门 一个数的数字根只和它mod~9mod 9之后的值有关,只要类似背包就能完成人员分配的计算。 注意处理全从a出或者全从b出的情况 #include "stdio.h" #include "st

2015-08-14 10:48:13 735

原创 HDU 5386 暴力

给出初始矩阵和目标矩阵,存在m中操作,可以分别把每行或者每列都涂成同一种颜色,数据保证有解 因为保证有解,所以初始矩阵完全没有用。。。 暴力寻找M次操作,若目标矩阵的行或列全和该操作的颜色一样,则最后进行此操作,并把所有涂的点涂为颜色0(可当任意颜色) 然后同样依次推出之前的操作,因为之后的操作会覆盖掉之前操作的点。 #include "stdio.h" #include "str

2015-08-13 22:48:48 898

原创 HDU 5372 线段树

给出两种操作: 第i个0:在x位置插入一个长度为i的线段,并输出该线段共覆盖了多少之前加入的线段 1:删除第i次插入的线段 官方题解:对于新插入的线段,查询有多少个线段左端点大于等于该线段的左端点。 再查询有多少个线段的右端点大于该线段右端点, 两者之差就是答案。用两个树状数组搞定。时间复杂度nlog 思路很好理解,直接用一个线段树记录区间的左端点和右端点即可 #include

2015-08-12 14:57:18 731

原创 HDU 5375 DP

模拟格雷码,给出格雷码每一位为1可得到的分数,然后给出一串二进制,之中'?'可为0或者1,求转换成格雷码的最大分数 二进制码→格雷码(编码): 此方法从对应的n位二进制码字中直接得到n位格雷码码字,步骤如下: 对n位二进制的码字,从右到左,以0到n-1编号 如果二进制码字的第i位和i+1位相同,则对应的格雷码的第i位为0,否则为1(当i+1=n时,二进制码字的第n位

2015-08-12 10:06:09 581

原创 HDU 5374 模拟俄罗斯方块

模拟俄罗斯方块游戏 完全按照俄罗斯方块的规则来做 注意规则即可: 1:每种图形开始出现时绿点均在(4,9)位置 2:先做变换,再下降一格 3:若碰到操作无法被执行的则不执行,依次进行下个操作 #include "stdio.h" #include "string.h" struct Type { int a,b,x,y; }type; char str[1010];

2015-08-11 17:00:24 535

原创 leetcode 题解代码整理 16-20题

3Sum Closest Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that e

2015-08-11 10:13:47 796

原创 leetcode 题解代码整理 11-15题

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 

2015-08-10 15:20:47 517

原创 leetcode 题解代码整理 6-10题

ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legi

2015-08-05 15:11:09 1523

原创 leetcode 题解代码整理 1-5题

Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to th

2015-08-04 21:38:53 595

原创 二叉树的基本使用

创建树,前序遍历,中序遍历,后序遍历,查找二叉树结点个数,查找二叉树叶子结点个数,查找二叉树度数为1的结点的个数 #include "iostream" using namespace std; struct tree { int data; tree *left,*right; }; class Tree { static int n; st

2015-08-02 22:08:00 1100

原创 链表的基本使用

链表的基本使用 创建链表,添加元素,删除元素 #include "iostream" using namespace std; struct node { int data; node *next; }; class list { node *head; public: list() { head=NULL; }

2015-08-02 15:28:26 433

空空如也

空空如也

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

TA关注的人

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