自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 k8s学习之路

k8s学习之路

2022-09-27 18:07:33 70

转载 c++ STL 容器

【转自:http://www.cppblog.com/tankzhouqiang/archive/2011/06/02/147939.html】参考:STL源码分析(一)vector容器vector的数据安排以及操作方式,与array非常相似。两者的唯一区别在于空间的运用的灵活性。array是静态空间,一旦配置了就不能改变。vector是动态空间,随着元素的加入,它的内部机制会自行扩充空间

2015-03-18 14:50:18 561

原创 【LeetCode笔记】Rotate Array

写了两种方法1. 用STL函数void rotate(int num[], int n, int k){ k %= n; if(k == 0) return; reverse(num, num + n); reverse(num, num + k); //[0..k-1] reverse(num + k, num +

2015-03-10 09:38:35 520

原创 【LeetCode笔记】Compare Version Numbers

int compareVersion(string version1, string version2) {stringstream s1(version1), s2(version2);while(1){int i1= 0, i2 = 0;if(getline(s1, version1, '.')) //if读取成功,将字符串convert为整型i1 = stoi(ver

2015-03-09 05:43:25 656

原创 Amazon电面题目-sort 100 IP addresses

第一次面试,有点紧张,犯了许多错误,电面就挂了。回头题目自己写下。不知道对不对。题目:排序100个IP地址,其中可能有非法的IP(例如:192.168.2.1.11 ,192.256.7.1,192.010.2.1)#include#include#include#include#includeusing namespace std;//s1=s2

2015-03-07 06:37:41 809

原创 关于stringstream重复使用时的问题2

string s1("333.444.555"); string s2("666.777.888");stringstream ss;string w1, w2;ss getline(ss, w1, '.');ss >> s1;cout ss.str("");// ss.clear();ss getline(ss, w2, '.');ss

2015-03-07 05:56:19 695

原创 关于stringstream重复使用时的问题

1.clear()与str("")测试代码string s1("333.444.555");string s2("666.777.888");stringstream ss;string w1, w2;ss getline(ss, w1, '.');cout ss.clear(); // ss.str("");ss getline(ss, w

2015-03-07 05:34:38 1291

原创 【LeetCode笔记】String to Integer (atoi)

用了几个Character handling functions,简化了代码。挺实用的。 (ctype.h)Character handling functionsThis header declares a set of functions to classify and transform individual characters.FunctionsThese fun

2015-02-13 12:57:46 454

原创 回溯和DFS的区别

Definition:Backtracking is a general algorithm for finding all (or some) solutions to some computational problems, notably constraint satisfaction problems, that incrementally builds candidates to t

2014-12-22 17:49:40 3674

原创 【LeetCode笔记】Wildcard Matching 和 Regular Expression Matching

这两道题第一眼看上去都差不多,通常思路就是用动态规划做。对于Regular Expression Matching可以50ms通过所有test case; 而对于Wildcard Matching却需要900ms.不知道OJ用了什么不同的test case,但是DP的时间复杂度是M*N的,没道理差别这么大。Dissuss里很多人用DP还不能通过。原因可能如下:boo

2014-12-22 12:12:01 1370

原创 【LeetCode笔记】Merge Intervals

用STL sort重写Compare时发生了一个错误,以前没有注意到的。我第一次写的:struct MyCmp{bool operator()(const Interval a, const Interval b){return (a.start }}mycmp;在运行是得到了Runtime Error。后来把 简单测试了一下:Input:(50,60)

2014-11-30 09:09:13 514

原创 【LeetCode笔记】Best Time to Buy and Sell Stock II

这个笔记跟这个题目没有多大关系。

2014-10-09 11:54:56 491

原创 【LeetCode笔记】Regular Expression Matching

Recursive method:bool isMatch(const char *s, const char *p) { //p is empty if(*p == '\0') return (*s == '\0'); //p is not empty //a * is followed if(*(p + 1) == '*'){ //take 0 preceding

2014-10-06 09:30:19 573

原创 【LeetCode笔记】Palindrome Partitioning

2 DP methods are used in this implementation:1. DP method to find all palind

2014-10-04 07:48:23 462

原创 【LeetCode笔记】Longest Palindromic Substring

Implement the Manacher’s algorithm

2014-10-01 06:54:17 559

原创 【LeetCode笔记】Candy

Something wrong with my solution as describing below.I got a wrong answer: Input: [1,2,4,4,3] Output: 10 Expected: 9my output is 1+2+3+3+1 = 10. and I think OJ's is 1+2+3+2+1 = 9how can

2014-08-28 14:40:25 615

转载 【LeetCode笔记】Word Break

Bottom up DPclass Solution {public: bool wordBreak(string s, unordered_setstring> &dict) { int len = s.length(); vectorbool> dp(len + 1,false); dp[len] = true;

2014-08-26 06:19:17 515

原创 【LeetCode笔记】Linked List Cycle

Set a fast runner and a slow runner. The fast runner jumps 2 nodes at one time, and the slow runner jumps 1 nodes at one time.

2014-07-10 03:44:13 533

原创 【LeetCode笔记】Reverse Integer

1. If want to reuse the same stringstream object, need to clear the buffer before use.

2014-07-08 23:44:29 503

转载 c++操作符及其优先级

From greatest to smallest priority, C++ operators are evaluated in the following order:LevelPrecedence groupOperatorDescriptionGrouping1Scope::scope qualifierLeft-to-righ

2014-07-01 09:01:54 660

转载 【Android】推荐学习路线图

2014-06-28 14:31:51 439

原创 Android Google Maps开发笔记:【2】如何配置AndroidManifest.xml文件

1.在元素中加入子标签    android:name="com.google.android.maps.v2.API_KEY"   android:value="your_api_key"/>其中your_api_key置换成自己申请的API Key。2. 中加入一些许可信息            android:name="com.example.mapde

2014-06-28 14:29:27 787

原创 Android Google Maps开发笔记:【4】如何解决添加Google Maps Project无法运行

在AndroidManifest.xml文件中加入            android:name="com.google.android.gms.version"            android:value="@integer/google_play_services_version" />

2014-06-28 14:27:02 587

原创 Android Google Maps开发笔记:【3】如何配置emulator正确运行GoogleMaps程序

Android Google Maps开发笔记:3.如何配置emulator正确运行GoogleMaps程序Update the emulator:Download the new files for latest play services:com.google.android.gms_20130908.apkcom.android.vending_2

2014-06-28 14:26:28 620

原创 Android Google Maps开发笔记:【1】如何获取 Google Maps API key

1.获取SHA-1 fingerprint Eclipse中的Windows > Prefs > Android > Build2.获取API Key网址:https://code.google.com/apis/console/    在左边的导航条中选择API Access。  在出来的页面中选择Create New Android Key   

2014-06-28 14:21:33 481

转载 【未名空间】一些oop的概念

The candidate should be able to give satisfactory definitions for a randomselection of the following terms:class, object (and the difference between the two)instantiationmethod (as opposed to,

2014-06-28 14:17:52 687

转载 C++ sizeof用法

C++ sizeof用法.sizeofsizeof操作符的作用是返回一个对象或类型名的长度,长度的单位是字节。返回值的类型是标准库命名为size_t的类型,size_t类型定义在cstddef头文件中,该头文件是C标准库的头文件stddef.h的C++版本。他是一个和机器相关的unsigned类型,其大小足以保证内存中对象的大小。 1、什么是sizeof  首先看一下siz

2014-06-28 14:08:54 597

随机算法笔记(英文)

随机算法(英文) 作者:James Aspnes

2014-10-04

空空如也

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

TA关注的人

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