自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 3. Longest Substring Without Repeating Characters(map用法)

Given a string, find the length of the longest substring without repeating characters.class Solution {public: int lengthOfLongestSubstring(string s) { map<char,int> record; ...

2018-11-27 17:56:05 152

转载 C++map用法详解

转自:https://www.cnblogs.com/fnlingnzb-learner/p/5833051.htmlMap是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。这里说下map内部数据的组织,map内部自建一颗红黑...

2018-11-27 16:38:55 768

原创 9. Palindrome Number(注意swap函数用法)

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.class Solution {public: string reverseString(string s) { int i=0,j=s...

2018-11-26 11:09:08 240

转载 C++ reverse函数的用法

转载自:https://cloud.tencent.com/developer/article/1150743逆序(反转)无论是在C或是C++中用的都特别多,常用于数组,字符串,容器等,其本身的函数参数也不复杂。       标准C中是没有recerse()函数的,这是C++的一个新增函数,使用需要包含头文件#include <algorithm>       rev...

2018-11-26 10:57:16 37710

转载 C++ int与string的相互转换

一、int转换成string  Ⅰ、to_string函数c++11标准增加了全局函数std::to_string:string to_string (int val);string to_string (long val);string to_string (long long val);string to_string (unsigned val);string t...

2018-11-26 10:44:16 349

原创 11. 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). Find two...

2018-11-09 10:39:46 123

原创 908. Smallest Range I

Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and add x to A[i].After this process, we have some array B.Return the smallest possible difference ...

2018-11-09 09:48:50 120

转载 erlang学习笔记--------mnesia数据库

作者:陈峰来源:博客园原文:https://www.cnblogs.com/freebird92/archive/2011/12/22/2296038.html事务及其它访问事务属性,包括原子性,一致性,隔离性,持久性 锁 脏操作 记录名字与表名字 活动概念与访问上下文 嵌套事务 模式匹配 Iteratoin1、事务属性Mnesia事务就是将一系列数据库操作封装在一...

2018-11-08 14:56:26 879

转载 Erlang中的record与宏

http://www.cnblogs.com/me-sa/archive/2011/07/20/erlang0006.html

2018-11-08 09:56:10 311

原创 Add Two Numbers

MyAnwser:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ...

2018-11-07 16:33:55 139

转载 erlang学习笔记--------运算符

Erlang运算符:        1、算术运算符:  +, -, *, /, div,  rem,                 1、"/", 用于除,但是其结果永远是浮点数, 即不管是否整除                2、div, 除, 取结果的整数部分                3、rem,  取模        2、比较运算符: >, <, &gt...

2018-11-07 15:22:45 1444

原创 习题8.8

在精确的4SAT问题中,输入为一组子句,每个子句都是恰好4个文字的析取,且每个变量最多在每个子句中出现一次。目标是求它的满足赋值——如果改赋值存在。证明精确的4SAT是NP-完全问题。首先对于在3SAT实例中某个子句中出现多次的变量,如果完全相同,则可简化为一次,如果包含了肯定已经否定,那么表明这个子句一定为真,因此无意义,可以直接从这组子句中去掉。处理之后的3SAT实例中每个变量则最

2017-07-14 14:07:29 412

原创 376. Wiggle Subsequence

A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either pos

2017-06-11 22:50:27 198

原创 486. Predict the Winner

Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a

2017-06-01 19:16:32 186

原创 96. Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2017-06-01 18:10:25 219

原创 413. Arithmetic Slices

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:

2017-05-21 22:14:05 210

原创 474. Ones and Zeroes

In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue.For now, suppose you are a dominator of m0s andn1s respectively. On the oth

2017-05-13 14:34:32 200

原创 121. Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2017-05-07 15:06:12 366

原创 392. Is Subsequence

Given a string s and a stringt, check ifs is subsequence oft.You may assume that there is only lower case English letters in boths andt.t is potentially a very long (length ~= 500,000)

2017-04-29 15:02:42 300

原创 Queue Reconstruction by Height

Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers(h, k), whereh is the height of the person andk is the number of people in front of th

2017-04-20 22:30:00 276

原创 122. Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one

2017-04-15 15:12:30 204

原创 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.Subscribe to see which companies a

2017-04-09 15:02:03 285

原创 Friend Circles

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is adirect friend of C, th

2017-04-03 18:38:41 459

原创 515. Find Largest Value in Each Tree Row

You need to find the largest value in each row of a binary tree./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; *

2017-03-26 12:58:25 206

原创 Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree./** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *ri

2017-03-18 14:00:36 300

原创 Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has

2017-03-12 14:52:14 184

原创 Majority Element

Given an array of size n, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element al

2017-03-04 13:40:15 214

原创 338. Counting Bits

Given a non negative integer number num. For every numbersi in the range0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5

2017-02-26 01:49:48 350

空空如也

空空如也

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

TA关注的人

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