自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 解决 docker mysql 中文乱码问题

docker mysql 字符集设置使用 docker 启动 mysql 容器可能会出现中文乱码的情况,这里记录如何制作支持中文的 mysql 镜像docker版本:18.06mysql 版本:5.71. 创建 my.cnf 文件[client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld]...

2020-02-15 19:13:53 1264

原创 Linux下修改Docker默认存储位置

修改 docker 存储位置在 centos7 系统中,docker 默认安装存储位置为 /var/lib/docker。当镜像多了以后,会占用大量的存储空间,当所在的分区存储空间不足时,我们可以通过扩展磁盘空间,或者修改 docker 配置中的存储位置来解决上述问题。0. 确定存储位置我们可以通过 docker info | grep "Docker Root Dir"命令查看docker...

2020-02-15 14:30:13 3981 3

原创 Ubuntu16.04安装docker

Ubuntu16.04安装docker本文中的内容翻译自官方文档,原文地址:点击跳转 Docker分为企业版(Docker EE )和社区版(Docker CE),企业版功能多,但是收费;社区版免费,适合小型企业和组织以及开发者,因此,在这里选择社区版。1. 准备工作1.1 系统要求首先系统需要64位的,可以选择以下Ubuntu的版本:Zesty 17.04Xenial 16.04 (L

2017-11-01 13:45:21 2080 1

原创 Leetcode--283. Move Zeroes

题目Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your fun

2017-09-30 16:01:27 370

原创 Leetcode--670. Maximum Swap

题目Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.Example 1: Input: 2736 Output: 7236 Explanatio

2017-09-04 21:31:59 1348

原创 Leetcode--50. Pow(x, n)

题目Implement pow(x, n).思路递归的方式,递归关系可以表示为 pow(x,n) = pow(x,n/2)*pow(x,n-n/2),从而将时间复杂的降到O(logn)代码class Solution {public: double myPow(double x, int n) { if(n==0) return 1.0;

2017-08-29 15:27:14 355

原创 Leetcode--338. Counting Bits

题目Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you

2017-08-27 20:50:31 300

原创 Leetcode--655. Print Binary Tree

题目Print a binary tree in an m*n 2D string array following these rules:The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number. The

2017-08-09 09:47:11 403

原创 Leetcode--Add to List 374. Guess Number Higher or Lower

题目We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I’ll tell you whether the number is higher o

2017-08-02 11:00:13 258

原创 Leetcode--Add to List 371. Sum of Two Integers

题目Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3. 不使用+ - 实现加法思路位运算来实现代码递归版本class Solution {public: int ge

2017-08-02 10:34:12 250

原创 Leetcode--648. Replace Words

题目In English, we have a concept called root, which can be followed by some other words to form another longer word - let’s call this word successor. For example, the root an, followed by other, which c

2017-07-25 10:54:11 974

原创 Leetcode--60. Permutation Sequence

题目The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):“123” “132” “213” “231” “31

2017-07-03 11:14:12 310

原创 Leetcode--Add to List 215. Kth Largest Element in an Array

题目Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k = 2, return 5. 寻找

2017-07-03 11:05:23 344

原创 Leetcode--139. Word Break

题目Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may ass

2017-07-03 10:54:57 332

原创 Leetcode--Add to List 201. Bitwise AND of Numbers Range

题目Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4. 数字范围位相与思路直接平移m和n,每次向右移一

2017-07-01 15:34:22 303

原创 Leetcode--191. Number of 1 Bits

题目Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 00000000000

2017-07-01 13:18:16 363

原创 40亿个非负整数中找到没出现的数

题目原问题:32位无符号整数的范围是0-4294967295,现在有一个正好包含40亿个无符号整数的文件,所以在整个范围中必然有没出现过的数。最多一可使用1GB的内存空间,怎么找到左右没出现过的数?进阶:内存限制为10MB,但是只用找到一个没有出现过的数即可。思路1、原问题如果用哈希表来保存出现过的数,那么如果40亿个数都不同,则哈希表记录为40亿条,每条记录占4B,共占用内存40亿*4B=1

2017-07-01 11:33:27 729

原创 只用2GB内存在20亿个整数中找到出现次数最多的数

题目有一个包含20亿个全是32位整数的大文件,在其中找到出现次数最多的数,内存限制为2GB。思路在整数中找到出现次数最多的数,通常做法是使用哈希表对出现的每一个数做词频统计,Key为整数,Value为出现的次数。本题中,32位的整数作为Key,需要4B空间,Value最大值为20亿(在20个数均为同一个数的情况下),用32位的整数完全可以存储,也需要用4B内存空间,这样,一个键值对需要占用8B的内存

2017-07-01 10:50:15 906

原创 Leetcode--189. Rotate Array

题目Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as you can, th

2017-07-01 10:28:02 299

原创 Leetcode--137.Single Number II

题目Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you

2017-06-30 20:32:07 344

原创 Leetcode--136.Single Number

题目Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra

2017-06-30 20:01:51 248

原创 Leetcode--326. Power of Three

题目Given an integer, write a function to determine if it is a power of three.Follow up: Could you do it without using any loop / recursion?Credits: Special thanks to @dietpepsi for adding this problem

2017-06-30 19:50:01 260

原创 Leetcode--89. Gray Code

题目The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gra

2017-06-30 19:26:20 341

原创 Leetcode--231、Power of Two

题目Given an integer, write a function to determine if it is a power of two.思路如果是2的幂,则二进制的所有位中,有且仅有一个1。 可以复用 “Number of 1 Bits” 中的函数,计算出1的个数,如果为1,则返回true, 不为1,返回 false。 还有更巧妙的办法。如果一个数是2的幂,则它的二进制最高位必然为1

2017-06-30 17:25:29 226

原创 Leetcode--268. Missing Number

一、题目Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2.Note: Your algorithm should run in

2017-06-30 16:26:58 265

原创 Leetcode--476. Number Complement

一、题目Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: The given integer is guaranteed to fit within the range of a

2017-06-30 15:48:49 226

原创 Ubuntu-Python2.7安装 scipy,numpy,matplotlib

sudo apt-get install python-scipysudo apt-get install python-numpysudo apt-get install python-matplotlibpythonimport scipyimport numpyimport pylabscipy.test()numpy.test()pylab.test()

2017-06-02 16:11:31 3952 1

原创 Ubuntu下安装hbase

1、在清华镜像站点下载hbase的安装文件,下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/ 2、解压放在/usr/local的目录下 3、修改权限sudo chown -R hduser hadoop hbase-1.2.5/4、修改文件夹的名称为hbase 5、在 /etc/profile中添加export HBASE_HOME

2017-05-19 17:21:13 1585

原创 vmware虚拟机:ubuntu server安装vmware tools

1、以root身份登录ubuntu 2、vmware中选择菜单虚拟机->安装VMware Tools 3、ubuntu命令行输入# mount -t iso9660 /dev/cdrom /mnt # cd mnt# cp VMWareTools-9.9.3-2759765.tar.gz /tmp# cd ..# unmount /dev/cdrom# cd /tmp# tar zx

2017-04-30 20:08:34 696

原创 Intel80x86内存寻址

Intel80x86内存寻址一、内存地址地址分为三种:逻辑地址 使用这种地址指定一个操作数或一条指令的地址,由16位的段(segment)和32位的偏移量(offset)组成线性地址 32位无符号整型,最高可表示4GB地址,通常用16进制数字表示,值的范围从0x00000000到0xffffffff。物理地址 用于芯片级内存单元寻址,由32位无符号整数表示CPU通过分段单元把一个逻辑地

2017-04-28 09:31:26 777

原创 ubuntu下mpich的安装与使用

在Ubuntu下安装mpich1、安装mpich在装之前,请确保以下软件都已经安装$gcc --version $g++ --version $python --version如果缺少相应的软件,先安装。 安装好以后,即可进入用以下命令安装mpich$ sudo apt-get install mpich等待安装完成后,测试安装结果$ which mpic

2017-04-27 22:32:44 9004

原创 Ubuntu16.04安装Oracle JDK

先测试系统中是否已经装过,用命令:java -version如果你看到像下面的输出,这就意味着你并没有安装过Java:The program ‘java’ can be found in the following packages:*default-jre*gcj-4.6-jre-headless*openjdk-6-jre-headless*gcj-4.5-jre-headless*o

2017-04-25 15:43:21 2597 3

原创 Ubuntu无法找到add-apt-repository问题的解决方法

新装的ubuntu出现无法找到add-apt-repository的问题,网上查了一下资料,原来是需要 : python-software-properties 用命令:apt-get install python-software-properties除此之外还要安装 software-properties-common 用命令:apt-get install software-properti

2017-04-25 15:37:58 1955

原创 Ubuntu16.04设置静态IP

ubuntu14.04设置静态ip1、找到文件并作如下修改:sudo vim /etc/network/interfaces修改如下部分:auto eth0 iface eth0 inet static address 192.168.0.100 #设置自己的ip地址 gateway 192.168.0.1 #自己的网关地址 netmask 255.255.255.0 #设置子网掩

2017-04-25 15:33:05 2229

原创 c语言函数返回值问题

C语言中,调用函数结束时,如果有返回值,会涉及到函数返回值传递问题,根据返回值的大小,会有不同的处理方式。 一、返回值小于等于4个字节 函数执行完毕后,如果返回值小于等于4字节,则会将值保存在寄存器eax中,然后在调用函数中通过读取eax的值来获得返回值。 二、当返回值大小在[5, 8]字节范围内时 因为eax寄存器只有四个字节,因此,当返回值在[5, 8]字节范围内时,一般采用eax和ed

2017-04-23 22:00:06 4344

原创 函数调用栈理解

一、相关寄存器(1) esp:栈指针寄存器(extended stack pointer),其内存放着一个指针,该指针永远指向系统栈最上面一个栈帧的栈顶。 (2) ebp:基址指针寄存器(extended base pointer),其内存放着一个指针,该指针永远指向系统栈最上面一个栈帧的底部。(ebp在当前栈帧内位置固定,故函数中对大部分数据的访问都基于ebp进行) (3) eip:指令寄存器

2017-04-23 21:43:05 462

转载 C语言的代码内存布局详解

一个程序本质上都是由 BSS 段、data段、text段三个组成的。这样的概念在当前的计算机程序设计中是很重要的一个基本概念,而且在嵌入式系统的设计中也非常重要,牵涉到嵌入式系统运行时的内存大小分配,存储单元占用空间大小的问题。BSS段:在采用段式内存管理的架构中,BSS段(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域。BSS是英文Block Started by

2017-04-23 20:08:08 260

原创 C语言中函数参数的入栈顺序

C语言中函数参数入栈顺序的确是从右至左的,一个例子来证明:#include <stdio.h>void func(int x, int y, int z){ printf("x = %d at [%X]\n", x, &x); printf("y = %d at [%X]\n", y, &y); printf("z = %d at [%X]\n",

2017-04-23 20:03:44 530

转载 C语言中extern的用法

在C语言中,修饰符extern用在变量或者函数的声明前,用来说明“此变量/函数是在别处定义的,要在此处引用”。extern修饰变量的声明。举例来说,如果文件a.c需要引用b.c中变量int v,就可以在a.c中声明extern int v,然后就可以引用变量v。这里需要注意的是,被引用的变量v的链接属性必须是外链接(external)的,也就是说a.c要引用到v,不只是取决于在a.c中声明exte

2017-04-23 19:26:59 609

原创 memcpy及memmove函数详解

•memcpy是把src指向的对象中的size个字符拷贝到dest所指向的对象中,返回指向结果对象的指针. •memmove也是把src指向的对象中的size个字符拷贝到dest所指向的对象中,返回指向结果对象的指针,但这两个函数在处理内存区域重叠的方式不同.注意memmove这个函数名称中有”move”这个单词,而实际上src处的数据仍然还在,并没有真的被”移动”了!这个函数名称有它的历史原因,是

2017-04-20 21:48:07 1195

空空如也

空空如也

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

TA关注的人

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