自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Burrows–Wheeler transform

poj 1147http://poj.org/problem?id=1147字符串压缩,给出原字符串所有的移位字符串,按字典序排序,给出最后一列,还原第一行0001100110011001000111000还原:由最后一列得到第一列,将最后一列与第一列合并,排序得到第一列与第二列,循环得到所有的列压缩:字符串的重复出现,the,排序后he开头的字符串都以t结尾,

2014-03-12 11:44:48 1436

原创 Android http post 文件 bad request 400

一直出现bad request的错误,缺少httpclient-4.2.1.jarpublic class UploadUtil {private static final int TIME_OUT = 10 * 1000; // 超时时间    private static final String CHARSET = "utf-8"; // 设置编码    public

2013-11-26 10:40:56 4228

原创 上传图片至服务器

将Bitmap写为File写入SDCard中,权限 //在SDCard中创建与删除文件权限//往SDCard写入数据权限">判断SD卡是否存在private boolean ExistSDCard(){if(android.os.Environment.getExternalStorageState().equals(android.os.Env

2013-11-25 11:04:30 424

原创 LeetCode: Single Number

class Solution {public:    int singleNumber(int A[], int n) {        // Note: The Solution object is instantiated only once and is reused by each test case.        int ans = 0;        bool f

2013-10-05 14:32:17 443

原创 LeetCode: Single Number II

class Solution {public:    int num[32];        void fun(int a){        for(int i=0;i            if(a&(1                num[i]++;        }    }        int singleNumber(int A[], in

2013-10-05 14:25:49 369

原创 LeetCode: Copy List with Random Pointer

class Solution {public:    RandomListNode *copyRandomList(RandomListNode *head) {        // Note: The Solution object is instantiated only once and is reused by each test case.        RandomLi

2013-10-05 14:07:25 386

原创 LeetCode: Search for a Range

class Solution {public:    int getMinRange(int A[],int n,int target){        int low=0,hi=n-1,mid;        while(low            mid = low+(hi-low)/2;            if(A[mid]                l

2013-10-04 09:50:33 315

原创 LeetCode: Divide Two Integers

用long long来避免整数越界class Solution {public:    int divide(int dividend, int divisor) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        i

2013-09-29 15:13:30 329

原创 LeetCode: Implement strStr()

KMPclass Solution {public:    char *strStr(char *haystack, char *needle) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        int hlen,n

2013-09-29 15:04:02 329

原创 LeetCode: Remove Element

class Solution {public:    int removeElement(int A[], int n, int elem) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        int num = 0;   

2013-09-29 14:45:24 337

原创 LeetCode: Remove Duplicates from Sorted Array

记录重复的数字的次数class Solution {public:    int removeDuplicates(int A[], int n) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        if(n==0)

2013-09-29 14:43:04 364

原创 LeetCode: Generate Parentheses

动态规划的方法需要考虑重复的组合,1位1位的考虑比较简单class Solution {public:    vector ans;    int num;    void solve(int pi,int num,int n,string &s){        if(num>2*n-pi+1)            return;        if(p

2013-09-29 14:37:55 408

原创 LeetCode: Valid Parentheses

class Solution {public:    bool isValid(string s) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        stack st;        for(int i=0;i     

2013-09-29 11:12:44 366

原创 LeetCode: Remove Nth Node From End of List

不考虑节点不存在的情况class Solution {public:    ListNode *removeNthFromEnd(ListNode *head, int n) {        // Start typing your C/C++ solution below        // DO NOT write int main() function   

2013-09-29 11:06:27 405

原创 LeetCode: 3Sum

3层循环,剪枝,数据小class Solution {public:    vector > threeSum(vector &num) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        vector > ans;

2013-09-29 11:00:39 372

原创 LeetCode: Longest Common Prefix

class Solution {public:    string longestCommonPrefix(vector &strs) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        string ans = "";   

2013-09-29 10:46:39 374

原创 LeetCode: Container With Most Water

class Solution {public:    int maxArea(vector &height) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        int ans = 0;        if(height.si

2013-09-29 10:39:41 386

原创 LeetCode: Regular Expression Matching

似乎“.*”能匹配任意的字符串,如“abcd”class Solution {public:    bool isMatch(const char *s, const char *p) {        // Start typing your C/C++ solution below        // DO NOT write int main() function

2013-09-29 10:27:35 411

原创 LeetCode: Palindrome Number

一般都需要用base来计数,排除数字中0的影响class Solution {public:    bool isPalindrome(int x) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        if(x

2013-09-29 09:28:22 373

原创 LeetCode: String to Integer (atoi)

class Solution {public:    int atoi(const char *str) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        bool flag = false,flag2=true;   //fl

2013-09-28 23:21:05 396

原创 LeetCode: Reverse Integer

class Solution {public:    int reverse(int x) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        bool flag = true;        if(x

2013-09-28 22:51:34 362

原创 LeetCode: Longest Palindromic Substring

Manacher’s Algorithmclass Solution {public:    string longestPalindrome(string s) {        // Start typing your C/C++ solution below        // DO NOT write int main() function       

2013-09-28 22:45:19 353

原创 LeetCode: Add Two Numbers

链表class Solution {public:    ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        int ad

2013-09-28 22:25:38 367

原创 LeetCode: Longest Substring Without Repeating Characters

记录每个字符上次出现的位置,pri表示所有字符从pri+1开始都不重复class Solution {public:    int lengthOfLongestSubstring(string s) {        // Start typing your C/C++ solution below        // DO NOT write int main()

2013-09-28 22:18:03 343

原创 LeetCode: Median of Two Sorted Arrays

查找第k大的数class Solution {public:    double findKthElem(int A[],int m,int B[],int n,int k){        int alow,amid,ahi,blow,bmid,bhi;        alow = 0,ahi = m-1,blow = 0,bhi = n-1;        wh

2013-09-28 21:50:12 782

原创 LeetCode: Two Sum

map与set都是利用红黑树实现的,适用于需要排序的地方。unordered_map,unordered_set都是利用hash来存储值,快速查找。class Solution {public:    vector twoSum(vector &numbers, int target) {        // Start typing your C/C++ soluti

2013-09-28 20:14:49 400

空空如也

空空如也

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

TA关注的人

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