自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 资源 (1)
  • 收藏
  • 关注

原创 520. Detect Capital

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word

2017-05-11 19:45:34 374

原创 521. Longest Uncommon Subsequence I

理解题意:最长不常见子序列被定义为,这些字符串之一的最长子序列,而这个子序列不应该是其他字符串的任何子序列。当最长不常见子序列不存在时,返回-1class Solution { public: int findLUSlength(string a, string b) { int row=a.length(); int col=b.length();

2017-05-11 19:39:13 295

原创 136. Single Number

题意理解:数组中的数只有一个出现了一次,找到这个数 分析:相同的两个数字异或为0,所以整个数组异或可得唯一只出现过一次的值class Solution { public: int singleNumber(vector<int>& nums) {//异或相同的值会消掉 int len=nums.size(); if(len==0)return -1;

2017-05-11 19:29:19 284

原创 485. Max Consecutive Ones

题意:寻找连续的1的个数,遍历一遍即可,用一个值来保存当前连续的1的个数class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { if(nums.size()==0)return 0; int maxn=0,len=nums.size(),count=0; for(int i=0;

2017-05-11 19:25:09 358

原创 292. Nim Game

题意理解:对于任何情况当给对方剩余4个石头时,我方是胜利的,所以只要是4的倍数,我方就是输的,否则必胜(给对手留下4的倍数的石头)class Solution { public: bool canWinNim(int n) { return n%4;//当选手的于的数为4的倍数,无论如何都会输,否则必胜 } };

2017-05-11 19:22:08 332

原创 动态规划:最长公共子序列与最长公共子串

1.问题描述: 公共子序列: 例如:acegs,cehkig中ceg为公共子序列,即子序列并不要求字符相连 2.求解算法: 母串:X=<x1x2x3x4x5...xm><x1x2x3x4x5...xm> Y=<y1y2y3y4y5...yn><y1y2y3y4y5...yn>, 求LCS和最长公共子串 a.暴力法:在X中找出所有

2017-05-11 19:15:10 333

原创 463. Island Perimeter

解题思路:对于每一个空格首先增加4条边,对于每个空格如果,右方和下方都是1,则相应的总计边数减2(抵消的是两条边)class Solution { public: int islandPerimeter(vector<vector<int>>& grid) { int row=grid.size(); if(row==0)return 0; int col=gr

2017-05-10 11:07:52 215

原创 496. Next Greater Element I

题意理解:找到findNums数组中每一个数在nums数组所在位置之后的比当前数大的数字,如果没有,保存-1class Solution { public: vector<int> nextGreaterElement(vector<int>& findNums, vector<int>& nums) { int len1=findNums.size(); int

2017-05-10 10:53:44 242

原创 566. Reshape the Matrix

题意理解:将现有矩阵,按照既定的行列转换class Solution { public: vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c) { vector<vector<int>> res(r,vector<int>(c)); int row=nums.size();

2017-05-10 10:39:33 286

原创 575. Distribute Candies

题意理解:每个数字代表一类,分给两个人,当两个人分得数目相同时,种类的最大数 种类的最大数:当总类别数小于总数/2,是总类别数 否则是总数/2class Solution { public: int distributeCandies(vector<int>& candies) { if(candies.size()==0

2017-05-10 10:25:32 446

原创 561. Array Partition I

题意理解:组成数组对,使得所有数组对中最小值的和最大class Solution { public: int arrayPairSum(vector<int>& nums) { int len=nums.size(); if(len==0)return 0; sort(nums.begin(),nums.end(),less<int>()); int coun

2017-05-10 10:13:08 333

基于B/S的在线考试系统

基于B/S的在线考试系统,实现自动生成题目,然后测试给分!

2014-03-29

空空如也

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

TA关注的人

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