- 博客(95)
- 资源 (42)
- 问答 (1)
- 收藏
- 关注
原创 LeetCode之Move Zeroes
1、题目Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, givennums = [0, 1, 0, 3, 12], after c
2017-03-31 00:23:46 2344
原创 LeetCode之Intersection of Two Arrays
1、题目Given two arrays, write a function to compute their intersection.Example:Givennums1=[1, 2, 2, 1],nums2=[2, 2], return[2].Note:Each element in the result must be uniq
2017-03-30 17:02:24 2485
原创 LeetCode之Add Digits
1、题目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. Since
2017-03-30 15:48:56 2260
原创 LeetCode之Ransom Note
1、题目Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the maga
2017-03-30 13:32:24 2530
原创 Bit Manipulation —— 位运算
1、介绍Bit Manipulation(位运算):一共五种运算:与,或,异或,左移,右移。2、算法题目一般使用总结:(1)n & (n-1)能够消灭n中最右侧的一个1。(2) 右移:除以2, 左移:乘以2。(3)异或性质:a1^a2^a3 = a2^a3^a1 交换律,0^a=a, a^a=0。
2017-03-30 01:17:03 2875
原创 LeetCode之Reverse String II
1、题目Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all
2017-03-29 23:40:59 2292
原创 Android之提示can‘t execute: Permission denied解决办法
1、问题在手机里面执行文件的时候提示can't execute: Permission denied一开始以为是没有root权限,自己傻逼了,错误意思是,不能执行,权限定义,2、解决办法chmod 777 file给文件可执行就可以。
2017-03-29 15:21:40 61858
原创 LeetCode之Find All Numbers Disappeared in an Array
1、题目Given an array of integers where 1 ≤ a[i] ≤n(n= size of array), some elements appear twice and others appear once.Find all the elements of [1,n] inclusive that do not appear in this
2017-03-29 11:18:28 2277
原创 LeetCode之Missing Number
1、题目Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]return2.Givennums=[0
2017-03-29 10:47:26 2399
原创 LeetCode之Find the Difference
1、题目Given two stringssandtwhich consist of only lowercase letters.Stringtis generated by random shuffling stringsand then add one more letter at a random position.Find the letter
2017-03-29 01:48:45 2358
原创 LeetCode之First Unique Character in a String
1、题目Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.
2017-03-29 00:08:49 2358
原创 LeetCode之Single Number
1、题目Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without
2017-03-28 20:17:41 2422
原创 LeetCode之Longest Common Prefix
1、题目Write a function to find the longest common prefix string amongst an array of strings2、代码实现package com.sangfor.leetcode;public class LongestCommonPrefix { public static void main(Stri
2017-03-27 21:39:14 2386
原创 LeetCode之Remove Element
1、题目Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant m
2017-03-27 19:00:54 2317
原创 LeetCode之Remove Duplicates from Sorted List
1、题目Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3.1->2->2->2 re
2017-03-27 17:55:07 2321
原创 LeetCode之Remove Duplicates from Sorted Array II
1、题目Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted arraynums=[1,1,1,2,2,3],Your function should return length =5, with th
2017-03-26 20:11:59 2300
原创 LeetCode之Remove Duplicates from Sorted Array
1、题目Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this in
2017-03-26 19:05:10 2359
原创 LeetCode之Max Consecutive Ones
1、题目Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are
2017-03-26 11:46:42 2347
原创 LeetCode之Nim Game
1、题目You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone w
2017-03-26 10:53:54 2434
原创 LeetCode之Island Perimeter
1、题目You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is c
2017-03-26 09:51:07 2480
原创 LeetCode之Next Greater Element I
1、题目You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nu
2017-03-25 21:35:06 2325
原创 LeetCode之Fizz Buzz
1、题目Write a program that outputs the string representation of numbers from 1 ton.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five outpu
2017-03-25 20:12:34 2399
原创 LeetCode之Keyboard Row
1、题目:Given a List of words, return the words that can be typed using letters ofalphabeton only one row's of American keyboard like the image below.Example 1:Input: ["Hello", "Ala
2017-03-25 00:56:05 2361
原创 LeetCode之Hamming Distance
1、题目TheHamming distancebetween two integers is the number of positions at which the corresponding bits are different.Given two integersxandy, calculate the Hamming distance.Note
2017-03-24 22:50:52 2310
原创 LeetCode之Reverse String
1、题目:Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".2、代码实现:代码实现1: public static String reverseStri
2017-03-24 22:28:48 2284
原创 LeetCode之Palindrome Number(回文数)
1、题目Determine whether an integer is a palindrome. Do this without extra space.2、代码实现代码实现1 public static boolean isPalindrome(int x) { if (x < 0) { return false; } String
2017-03-24 16:51:50 2385
原创 LeetCode之Reverse Integer
1、题目Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your func
2017-03-24 15:23:45 2326
原创 LeetCode之Two Sum
1、题目Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not u
2017-03-23 22:09:53 2358
原创 linux之vim常见配置
1、打开vim配置文件vim ~/.vimrc2、添加部分配置去掉讨的关vi一致性模式,避免以前版本的一些bug和局限set nocompatible显示行号set number检测文件的类型filetype on 记录历史的行数set history=1000 背景使用黑色(已经测试这个没有什么效果),加了会报错,建议大家不要加上set background
2017-03-23 17:50:49 2722
原创 ios之Xcode工程中添加文件常用快捷键
1、Xcode某个工程中添加文件有两种方式:方式一:“command”+“n”,弹出添加文件对话框。方式二:在需要添加文件的工程目录下右键,选择“New File…”。以上方式Xcode会弹出下面的对话框:左侧是使用Xcode做的工程类别的分类,我们选择“OS X“,在这个目录下,是所有可以添加的文件的分类,在“Source”中,右侧会显示一下几
2017-03-23 00:15:18 3233
原创 ios之最简单的程序
1、构建学生对象并且打印相关信息代码:#import #import "AppDelegate.h"@interface Student : NSObject//变量@property NSString *name;@property int age;@property float score;//method-(void)show;@end@implement
2017-03-22 23:55:57 2449
原创 C++之typename
1、typename和class在模板前,typename和class没有区别template class A;template class A;typename和class对编译器而言却是不同的东西2、声明一个类型看下面的代码我们编译下结果如下编译器不知道T::const_iterator是个类型。如果它是个变量呢? T::cons
2017-03-22 17:39:56 2423
原创 C++之operator关键字(重载操作符) 使用总结
operator是C++的关键字,它和运算符一起使用,表示一个运算符函数,一、为什么使用操作符重载简单的说我们基本数据比如int float 都可以比较大小 有>、、二、实现重载的操作符先看简单代码类成员函数实现重载和非类成员函数(全局函数)1)、操作符重载实现为类成员函数重载的操作符在类体中被声明,声明方式如同普通成员函数一样,只不
2017-03-22 15:48:47 11581
原创 C++之‘nullptr’ was not declared in this scope
在vim里面写了一个简单cpp文件,为了避免野指针,需要指针初始化char *p2 = nullptr1、编译时报错如下2、解决办法编译加上g++ -std=gnu++0x int.cpp -o int3、C里面的null和C++里面的nullptr、NULL介绍NULL在C++中的定义/* Define NULL pointer v
2017-03-22 12:03:28 29532
原创 C++之inline函数使用总结
一、C++为什么引入inline函数?主要目的:用它代替C语言中表达式形式的宏定义来解决程序中函数调用的效率问题。C语言中的宏定义,它使用预处理器实现,没有了参数压栈、代码生成等一系列得到操作,因此效率很高。但缺点如下:预处理器符号表中的简单替换,不能进行参数有效性的检测,不能享受C++编译器严格类型检查的好处。另外,它的返回值也不能被强制转换为可转换的合适类型。C++如果
2017-03-22 01:24:33 3834
原创 C++类与const关键字
1、const成员变量const 成员变量的用法和普通 const 变量的用法相似,只需要在声明时加上 const 关键字const 成员函数可以使用类中的所有成员变量,但是不能修改它们的值,这种措施主要还是为了保护数据而设置的2、const 成员函数也称为常成员函数。常成员函数需要在声明和定义的时候在函数头部的结尾加上 const 关键字,看下面的例子:c
2017-03-22 00:42:00 2485
原创 C++之explicit关键字使用总结
1、explicit关键字介绍C++中的explicit关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的, 而非隐式的, 关键字是implicit, 意思是隐藏的,类构造函数默认情况下即声明为implicit(隐式).2、贴代码#include #include #include #include using namespace
2017-03-21 22:07:24 2368
原创 C++之‘malloc’ was not declared in this scope和invalid conversion from ‘void*’ to ‘char*’
1、错误一‘malloc’ was not declared in this scope2解决加上头文件文件3、错误二invalid conversion from ‘void*’ to ‘char*’ 4、解决在malloc函数前面加上强转类型(char *)
2017-03-21 21:32:27 10194 2
转载 unix网络编程之UNIX Domain Socket IPC (sockaddr_un )
socket API原本是为网络通讯设计的,但后来在socket的框架上发展出一种IPC机制,就是UNIX Domain Socket。虽然网络socket也可用于同一台主机的进程间通讯(通过loopback地址127.0.0.1),但是UNIX Domain Socket用于IPC更有效率:不需要经过网络协议栈,不需要打包拆包、计算校验和、维护序号和应答等,只是将应用层数据从一个进程拷贝到另
2017-03-21 20:25:00 2965
原创 C++之invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
1、看代码2、编译结果3、分析和解决就拿f(a + b)来说,a+b的值会存在一个临时变量中,当把这个临时变量传给f时,由于f的声明中,参数是int&,不是常量引用,因为c++编译器的一个关于语义的限制。如果一个参数是以非const引用传入,c++编译器就有理由认为程序员会在函数中修改这个值,并且这个被修改的引用在函数返回后要发挥作用。但如果
2017-03-21 16:54:35 36060 7
Android之常用命令和工具.pdf
2021-04-01
math-basics.rar
2019-08-01
c_log_to_file.txt
2019-06-15
Source Insight黑色和灰色的背景配置
2019-04-23
Xshell5(Xshell5免费)
2019-03-21
linux shell脚本攻略2
2019-03-06
xshell(windows)
2018-12-05
Android打印当前app的日志工具类
2018-09-20
pidcat.py_in_ubuntu
2018-05-12
pc web access phone file
2017-12-25
MPAndroidChart让(折线图、柱形图、饼状图、散列图、雷达图)优雅的舞动
2015-11-30
手机摇一摇震动刷新(支持ListView GridView WebView)
2015-11-09
Android怎么sp怎么确保多进程
2018-05-23
TA创建的收藏夹 TA关注的收藏夹
TA关注的人