自定义博客皮肤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)
  • 收藏
  • 关注

原创 31. Next Permutation

题意: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible

2016-01-31 16:46:00 359

原创 27. Remove Element

题意:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn’t matter what you leave beyond the new length. AC代码:c

2016-01-29 16:50:49 326

原创 26. Remove Duplicates from Sorted Array

题意: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with

2016-01-29 16:12:45 305

原创 25. Reverse Nodes in k-Group

题意: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it i

2016-01-29 15:29:18 375

原创 24. Swap Nodes in Pairs

题意:Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You

2016-01-28 16:01:30 274

原创 23. Merge k Sorted Lists

题意:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 分析:堆排序

2016-01-25 10:10:31 397

原创 Hadoop伪分布式

Hadoop伪分布式配置 参考:http://www.powerxing.com/install-hadoop/ step1. 下载Hadoop2.6.0版本,解压到/usr/local/hadoop step2. 修改配置文件(配置文件地址:/usr/local/hadoop/etc/hadoop) 1).core-site.xml<configuration> <property

2016-01-22 17:14:28 341

原创 22. Generate Parentheses

题意: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: “((()))”, “(()())”, “(())()”, “()(())”, “()()(

2016-01-22 15:53:00 220

原创 21. Merge Two Sorted Lists

题意:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.class Solution {public: ListNode* mergeTwoLists(List

2016-01-22 10:43:39 206

原创 20. Valid Parentheses

题意描述:Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are all vali

2016-01-21 13:51:35 222

原创 19. Remove Nth Node From End of List

题意:Given a linked list, remove the nth node from the end of list and return its head.Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes

2016-01-21 13:27:51 201

原创 18. 4Sum

题意:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.分析:同3Sum一样的思路,多加了一层循环。

2016-01-21 12:52:04 272

原创 17. Letter Combinations of a Phone Number

题意:Given a digit string, return all possible letter combinations that the number could represent. Input:Digit string “23” Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”]. 思路:类似n进制数

2016-01-19 19:07:44 326

原创 16. 3Sum Closest

题意:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact

2016-01-19 15:51:22 247

原创 15. 3Sum

题意:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. 思路: 先排序,两层循环,外层表示求和的第一个数,内层循环设两个游标,指向剩余数

2016-01-19 15:49:23 238

原创 10. Regular Expression Matching

题意描述:Implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should cover the entire input

2016-01-15 10:55:47 401

原创 14. Longest Common Prefix

题意:Write a function to find the longest common prefix string amongst an array of strings. 分析:找最长前缀AC代码:string longestCommonPrefix(vector<string>& strs){ string prefix; int prefix_length = 0;

2016-01-13 15:57:00 232

原创 13. Roman to Integer

题意:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.AC代码:int romanToInt(string s){ int ret = 0; for(int i = 0; i < s.size(); ++i){

2016-01-13 15:23:11 257

原创 12. Integer to Roman

题意:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.分析: 数字对应罗马字符: I placed before V or X indicates one less, so four is IV (one less than fiv

2016-01-13 12:03:37 291

原创 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 tw

2016-01-13 09:20:26 256

原创 学习shell script

为了给我的LNMP写启动脚本,现在来跟鸟哥学习shell scriptscript执行方式直接执行(使用路径直接执行或使用bash/sh执行),会使用新的bash环境来执行脚本内的命令,其实实在子进程的bash内执行的,当子进程完成后,子进程的各项变量或操作将会结束不会传回到父进程中。source执行,会在父进程中执行。声明#!/bin/bashPATH=/bin:/sbin:~/bin

2016-01-07 20:43:05 321

转载 vim快捷键

NERDTreectrl+w+h #光标切换到左侧树形目录ctrl+w+l #光标切换到右侧文件显示窗口ctrl + w + w #光标自动在左右侧窗口切换ctrl + w + r #移动当前窗口的布局位置o #在已有窗口中打开文件、目录或书签,并跳到该窗口go #在已有窗口 中打开文件、目录或书签,但不跳到该窗口t #在新 Tab 中打开选

2016-01-07 17:34:53 264

原创 9. Palindrome Number

题意描述:Determine whether an integer is a palindrome(回文结构). Do this without extra space.AC代码:class Solution {public: bool isPalindrome(int x) { if(x < 0) return false; int

2016-01-07 14:54:10 244

原创 8. String to Integer (atoi)

题意描述:Implement atoi to convert a string to an integer. 需要注意的情况: 1. 正负号 2. 有效字符之前可能会有空格 3. 有效字符中出现非法字符会截断数字 4. 溢出时输出最大值或最小值AC代码:class Solution {public: int myAtoi(string str) { if(str.l

2016-01-07 10:19:28 315

原创 7. Reverse Integer

题意描述: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 错误解法:class Solution {public: int reverse(int x) { int sum = 0; while((x*10)/10)

2016-01-06 11:23:16 324

原创 LNMP服务器配置(mysql)

下载地址:http://dev.mysql.com/downloads/mysql/ select platform: Source Code Generic Linux (Architecture Independent), Compressed TAR Archive (mysql-5.6.28.tar.gz)安装mysql$sudo tar -zxvf mysql-5.6.28.tar.

2016-01-05 22:20:21 543

原创 6. ZigZag Conversion

题目描述:给定行数numRows, 将字符串按Z字排列,按行输出class Solution {public: string convert(string s, int numRows) { string ret_string; int len = s.length(); if(numRows == 1 || len <= numRows)

2016-01-05 16:50:02 334

原创 5. Longest Palindromic Substring

可悲的超时解法,runtime:130+msclass Solution{public: string longestPalindrome(string s){ string max_string; for(string::iterator loc_it = s.begin(); (loc_it + 1)!= s.end() ; loc_it ++){

2016-01-05 09:55:38 308

空空如也

空空如也

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

TA关注的人

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