自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 stl bitset

bool canPermutePalindrome(string s) { bitset<256> b; for (char c : s) b.flip(c); return b.count() < 2; }bitset就是里面装了bit的setcount (...

2016-03-31 05:44:00 159

转载 自定义compare 函数

//priority queue 可以用自定义的compare类struct compare{ bool operator()(const int& l, const int& r) { return l > r; }};int main(){   priority_queue<int,vec...

2016-03-14 04:32:00 310

转载 Implement Trie Tree,用memset做初始化

class TrieNode {public: bool exist; TrieNode* children[26]; TrieNode() { exist = false; memset(children, 0, sizeof(children)); }};class Trie {pub...

2016-02-28 13:03:00 100

转载 JAVA bugFree!

JAVA* while(count==0) {} // 不能写成while(count) java不会自己变类型* int i; long sqr = (long)i*i; // 要手动做类型转换* If you use thenextLine()method immediately following thenextInt()meth...

2016-01-30 10:34:00 108

转载 MySQL 笔记

create databasecreate TUTORIALS // create databasedelete databasedrop TUTORIALS // delete databseChange databaseuse TUTORIALS; // use database Data Type: http://www.runoob.com/mysql/mysql-...

2016-01-28 07:31:00 85

转载 C++ 继承

C++中public,protected,private访问小结第一:private,public,protected方法的访问范围.(public继承下)private: 只能由该类中的函数、其友元函数访问,不能被任何其他访问,该类的对象也不能访问.protected: 可以被该类中的函数、子类的函数、以及其友元函数访问,但不能被该类的对象访问public: 可以被该类中的函数、子...

2016-01-24 12:32:00 67

转载 流插入运算符为什么要被重载为全局函数?

https://www.coursera.org/learn/cpp-chengxu-sheji/lecture/c3tbl/liu-cha-ru-yun-suan-fu-he-liu-ti-qu-yun-suan-fu-de-zhong-zai 笔记Part 1. 流插入运算符的重载:cout<<5<<endl;...

2016-01-24 11:31:00 561

转载 C++ syntax

new:int *a = new int[size];int **a = new int*[size];运算符重载: // 输入输出运算符必须被重载为全局函数!class Complex{ public: int a,b;};Complex operator+(Complex &x, Complex &am...

2016-01-24 08:50:00 144

转载 Java PriorityQueue

heap insideQueue<Integer> qi = new PriorityQueue<Integer>();常用函数add()poll()peek()remove()contains()clear()转载于:https://www.cnblogs.com/XingyingLiu/p/5152775...

2016-01-23 04:27:00 61

转载 Java Cheatsheet

Hello, World.public class learn { public static void main(String[] args){ System.out.println("hi"); }}Built-in data types:int, double, boolean, char, String...

2016-01-23 04:08:00 199

转载 Java HashMap

HashMap<String, String> map = new HashMap<String, String>();map.put("1", "2");System.out.println(map.get("1"));常用函数:containsKey(key)put(key, value)remove(key)clear(...

2016-01-23 03:51:00 56

转载 JAVA Math

java.lang.Math APIhttps://docs.oracle.com/javase/7/docs/api/java/lang/Math.htmle.g. Math.max(a, b) 常用的有abs(a)ceil(a) floor(a) round(a) // 取整exp(a) // e^a p...

2016-01-23 02:47:00 55

转载 Java ArrayList

// ArrayListArrayList<String> myArr = new ArrayList<String>();myArr.add("one");myArr.add("two");System.out.println(myArr.get(0));//Vector Vector<String> myV =...

2016-01-22 12:41:00 59

转载 lower_bound, upper_bound

lower_bound 返回大于等于upper_bound 返回大于----------------------综合一下(按照默认集合升序排序的情况下),lower_bound、upper_bound函数不管在什么情况下,以下条件均成立。Iterator(val) ≤ Iterator(lower_bound)≤Iterator(upper_bound)也就是lowe...

2016-01-16 10:03:00 80

转载 string split

根据空格splitstring str = "abc def,ghi";stringstream ss(str);string token;while (ss >> token) cout<<token<<endl; output:abcdef,ghi根据指定字符splitvector<st...

2016-01-10 01:32:00 59

转载 C++ 数学运算

pow(2,3) // 2^3=8转载于:https://www.cnblogs.com/XingyingLiu/p/5115554.html

2016-01-09 10:34:00 114

转载 Bit Manipulation

从右起第一个为1的bit: a &-a; example:a = 4 //1100-a= -4 //0011+1 = 0100a&-a = 0100-----------------------------------------------作用于bit的逻辑运算符:& // and| // o...

2016-01-09 10:29:00 71

转载 stl stack

stack<int> mystack; //createmystack.push(1); mystack.pop(); // no return valuemystack.size();mystack.empty(); //trueif theunderlying container's size is0,falseotherwise.mysta...

2016-01-09 04:55:00 72

转载 C++ bugFree!

C++* 要写分号!* min/max函数只能比较两个数。 min(a,b,c) 会出错,要用 min(a,min(b,c))* min/max的输入不能一个是sizetype, 一个是int* void move(stack<int> &s1, stack<int> &s2) 不加引用时是值传递*...

2016-01-09 03:03:00 101

转载 stl priority queue

priority_queue优先队列容器与队列一样,只能从队尾添加(插入)元素,从队头(队首)删除元素。但他有一个特性,就是队列中最大的元素总是位于队首,所以出队时,并非按先进先出的原则进行,而是将当前队列中最大的元素出队。如果要删除中间元素,就要用heap转载于:https://www.cnblogs.com/XingyingLiu/p/5107889.html...

2016-01-06 23:44:00 65

转载 stl pair

// make_pair example#include <utility> // std::pair#include <iostream> // std::coutint main () { std::pair <int,int> foo; std::pair <int,int> bar;...

2016-01-06 23:28:00 59

转载 stl heap

// range heap example#include <iostream> // std::cout#include <algorithm> // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap#include <vector> ...

2016-01-06 09:11:00 63

转载 stl queue

定义queue对象的示例代码如下:queue<int> q1;queue<double> q2;queue的基本操作有:入队,如例:q.push(x); 将x接到队列的末端。出队,如例:q.pop(); 弹出队列的第一个元素,注意,并不会返回被弹出元素的值。访问队首元素,如例:q.front(),即最早被压入队列的元素。访问队尾元...

2016-01-06 05:09:00 357

转载 Algorithms

多数派问题()'''在O(n)时间复杂度,O(1)空间复杂度内,判断是否有候选人的得票数过半该算法在运行过程中,需要两个临时变量c和t,c记录当前可能得票数过半的候选人编号,t记录该候选人的净超出次数。对于c而言,除了可以等于1~m中的任何值之外,还有另一种状态,我们把其叫做未知状态,用于表示当前任何候选人的得票数都不可能过半(程序中可以用0,或者-1表示),t的最小值为0,程序...

2016-01-03 04:44:00 80

转载 substr(pos, len)

string substr (size_t pos = 0, size_t len = npos) const;// string::substr#include <iostream>#include <string>int main (){ std::string str="We think in generalitie...

2015-12-31 12:00:00 225

转载 string.length() 返回值是unsigned

int main(int argc, const char * argv[]) { // insert code here... string a = ""; cout<<a.size()<<endl; cout<<a.size()-1<<endl; cout<<a.len...

2015-12-31 11:56:00 140

转载 stl vector

初始化vector<int> chars(26, 0); // initialized as 26 zerosint myints[] = {10,20,30,5,15};std::vector<int> v(myints,myints+5);insertb.insert(b.end(), a.begin(), a.end()...

2015-12-30 06:49:00 61

转载 stl map

遍历mapit->first it->second#include<map>#include<string>#include<iostream>int main(){map<string,int> words;map<string,int>::iterator it=wor...

2015-12-30 06:48:00 53

转载 numeric_limits

// numeric_limits example#include <iostream> // std::cout#include <limits> // std::numeric_limitsint main () { std::cout << std::boolalpha; std::cout &...

2015-12-29 06:48:00 70

转载 stl set, multiset

#include<iostream>#include<string>#include<set>using namespace std;int main(){ set<string> strset; set<string>::iterator iter; strset.in...

2015-12-29 05:01:00 85

转载 Add Digits

Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + 8 = 11,1 + 1 = 2. Since2has only o...

2015-11-19 13:39:00 56

转载 Utopian Tree

Problem StatementThe Utopian Tree goes through2cycles of growth every year. The first growth cycle occurs during the spring, when itdoublesin height. The second growth cycle occurs during...

2015-11-09 04:44:00 82

转载 Sherlock and The Beast

Problem StatementSherlock Holmes is getting paranoid about Professor Moriarty, his arch-enemy. All his efforts to subdue Moriarty have been in vain. These days Sherlock is working on a pr...

2015-11-09 04:32:00 60

转载 Angry Professor

Problem StatementThe professor is conducting a course on Discrete Mathematics to a class ofNstudents. He is angry at the lack of their discipline, and he decides to cancel the class i...

2015-11-08 09:52:00 105

转载 Time Conversion

Problem StatementYou are given time in AM/PM format. Can you convert this into a 24-hour format?InputInput consists of time in the AM/PM format i.e. hh:mm:ssAM or hh:mm:ssPMwhere01...

2015-11-08 09:37:00 110

转载 C++ String与int转换

stoi() // string to intto_string() // int to string转载于:https://www.cnblogs.com/XingyingLiu/p/4946851.html

2015-11-08 08:57:00 51

空空如也

空空如也

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

TA关注的人

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