自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 python 解析json

python 解析json,输入文件内容{"happy":{"date":20201020}, "birth":19920103, "gender":"F"}代码#!/usr/bin/env python# -*- coding: utf-8 -*import reimport jsonimport osimport sysdef process(line, loginfo): """ 提取出符合条件的json """ if 'happy' in loginfo and 'd

2021-03-08 11:20:50 208

转载 C++sizeof

https://www.cnblogs.com/0201zcr/p/4789332.html

2019-11-05 10:38:42 202

原创 191.Fizz Buzz

题目Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. ...

2019-05-07 21:18:22 325

原创 190.Largest Perimeter Triangle

题目Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths.If it is impossible to form any triangle of non-zero area, retur...

2019-04-27 20:05:05 298

原创 189.Leaf-Similar Trees

题目Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence.For example, in the given tree above, the leaf value sequence is (6, 7,...

2019-04-27 19:40:29 168

原创 188.Range Sum of BST

题目Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to have unique values.Example 1:Inp...

2019-04-26 22:42:17 208

原创 187.Base 7

题目Given an integer, return its base 7 string representation.Example 1:Input: 100Output: “202”Example 2:Input: -7Output: “-10”Note: The input will be in range of [-1e7, 1e7].链接https://leetcod...

2019-04-26 22:13:53 167

原创 186.Add Strings

题目Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is < 5100.Both num1 and num2 contains only digits 0-...

2019-04-24 20:37:15 131

原创 185.1-bit and 2-bit Characters

题目We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).Now given a string represented by several bits. ...

2019-04-24 10:43:20 123

原创 184. Divisor Game

题目Alice and Bob take turns playing a game, with Alice starting first.Initially, there is a number N on the chalkboard. On each player’s turn, that player makes a move consisting of:Choosing any x ...

2019-04-23 21:41:20 259

原创 183.Univalued Binary Tree

题目A binary tree is univalued if every node in the tree has the same value.Return true if and only if the given tree is univalued.Example 1:Input: [1,1,1,1,1,null,1]Output: trueExample 2:Input: ...

2019-04-23 13:29:55 134

原创 182.Smallest Range II

参考https://blog.csdn.net/zjucor/article/details/82820938题目Given an array A of integers, for each integer A[i] we need to choose either x = -K or x = K, and add x to A[i] (only once).After this proce...

2019-04-22 22:52:27 215

原创 181.Smallest Range I

题目Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and add x to A[i].After this process, we have some array B.Return the smallest possible difference...

2019-04-21 17:13:31 342

原创 180.To Lower Case

题目Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.Example 1:Input: “Hello”Output: “hello”Example 2:Input: “here”Output: “here”Example...

2019-04-21 16:48:36 217

原创 179.Fibonacci Number

题目The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,F(0) = 0, ...

2019-04-21 16:30:26 122

翻译 C++编译时出现 reference to local variable

具体见:https://stackoverflow.com/questions/19371137/c-reference-to-local-variable-returned会引发问题的实现如下:vector&lt;int&gt; &amp; find1(string &amp;search_word){ vector&lt;int&gt; final;final.push_...

2018-11-09 15:59:09 6802 4

原创 atomic cas

2018-05-09 14:15:18 1766

原创 178.Custom Sort String

题目S and T are strings composed of lowercase letters. In S, no letter occurs more than once.S was sorted in some custom order previously. We want to permute the characters of T so that they match t...

2018-03-19 20:02:53 294

原创 177.Merge Two Binary Trees

题目Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary ...

2018-03-19 19:35:49 234

原创 176.Judge Route Circle

题目Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The move sequence is represente...

2018-03-14 21:33:10 211

原创 java、C++、python三种语言对比之类 class

需求实现一个简单的Student类,属性nameage方法默认构造函数带参数的构造函数两个属性的get和set方法测试,实现main方法测试Student类中的方法都可以用java定义一个Classpublic class Student { private String name; private int age; pub...

2018-03-14 19:13:23 1969

原创 175.Maximum Binary Tree

题目Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the maximum tree construct...

2018-03-14 18:28:31 144

原创 174.Jewels and Stones

题目You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the st

2018-03-13 17:24:00 222

原创 C++ 读文件

c++ 代码中读文件bool read_file(const char* path) { char line[MAX_FILE_LINE_LENGTH]; FILE *fp = NULL; fp = fopen(path, "r"); if (fp == NULL) { return false; } while (fgets...

2018-02-27 15:45:23 1713

原创 stork_k函数

stork_k函数strtok_r()函数用于分割字符串。strtok_r是linux平台下的strtok函数的线程安全版。windows的string.h中并不包含它。char *strtok_r(char *str, const char *delim, char **saveptr); strtok_r函数是strtok函数的可重入版本。str为要分解的字符串,delim为分隔符字

2018-02-06 11:00:02 575

转载 shell 中 if then语句中会跟着-ne -ge之类的语句

-eq:等于 -ne:不等于 -le:小于等于 -ge:大于等于 -lt:小于 -gt:大于

2017-12-06 11:44:36 7900

转载 shell脚本中与文件判断相关的指令

-e filename 如果 filename存在,则为真 -d filename 如果 filename为目录,则为真 -f filename 如果 filename为常规文件,则为真 -L filename 如果 filename为符号链接,则为真 -r filename 如果 filename可读,则为真 -w filename 如果 filename可写,则为真 -x fi

2017-12-06 11:29:45 501

原创 C++ gcc 程序时出问题

/sbin/../lib/gcc/x86_64-baidu-linux-gnu/4.8.2/../../../../x86_64-baidu-linux-gnu/bin/ld: /tmp/cc2R3lJb.o: undefined reference to symbol ‘ceil@@GLIBC_2.2.5’ /sbin/../lib/gcc/x86_64-baidu-linux-gnu/4.8.

2017-11-09 19:12:49 552

转载 linux之sort用法

转载自

2017-10-26 11:25:07 271

原创 编译出现问题

出现问题/tmp/cc5607Wr.o: In function bool boost::regex_match<char const*, std::allocator<boost::sub_match<char const*> >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char

2017-10-23 11:03:20 2218

原创 python 遍历文件夹

文件夹A A-1.txt A-2.txt A-AA A-AA-11.txt 1.只遍历给定路径下的文件名 import os def eachFile(filepath): #遍历指定目录,显示目录下的所有文件名 pathDir = os.listdir(filepath) for allDir in pathDir: child = os.pa

2017-10-19 10:29:06 362

转载 linux命令求两个文件的交集、差集、并集等

LANG=C;sort file1 file2 | uniq 两个未排序文件的并集 LANG=C;sort file1 file2 | uniq -d 两个未排序文件的交集 LANG=C;sort file1 file1 file2 | uniq -u 两

2017-10-10 10:58:01 1923

原创 replication factor: 1 larger than available brokers: 0 问题解决方案

出现这个问题的原因是kafka没有启动的情况下想去create tpoic,所以应该是先去进到kafka安装目录的bin路径下,执行./kafka-server-start.sh ../config/server.properties 打开kafka即可!

2017-10-03 17:01:29 18780

原创 C++中的声明语句

一条声明语句的目的是令程序知晓某个名字的存在以及该名字表示一个什么样的实体,如一个类、一个函数、一个变量等;int a;//声明一个变量int f();//声明一个函数class A{}A a;//声明一个类

2017-09-29 13:26:10 3497

原创 C++正则表达式提取匹配到的字符串

/* * 输入是789.123.456, 输出的是789 */void get(){ std::regex ip_reg("(.*)\.123\.456"); std::smatch matchResult; string inputStr; std::getline(std::cin,inputStr); //正则匹配

2017-09-29 10:24:44 30392 2

转载 linux中用cut命令

linux之cut用法 cut是一个选取命令,就是将一段数据经过分析,取出我们想要的。一般来说,选取信息通常是针对“行”来进行分析的,并不是整篇信息分析的。(1)其语法格式为: cut [-bn] [file] 或 cut [-c] [file] 或 cut [-df] [file]使用说明 cut 命令从文件的每一行剪切字节、字符和字段并将这些字节、字符和字段写至标准输出。 如果不指

2017-09-13 14:37:09 279

转载 printf 格式化输出符号详细说明

转载自:http://blog.csdn.net/xiexievv/article/details/6831194 %a 浮点数、十六进制数字和p-记数法(C99) %A    浮点数、十六进制数字和p-记法(C99) %c     一个字符(char) %C 一个ISO宽字符 %d    有符号十进制整数(int)(%ld、%Ld:长整型数据(

2017-09-11 17:23:11 1160

转载 gflags命令行参数

写服务程序时,如果需要提供命令行参数。传统的方法是手工解析argv参数,或者使用getopt函数。两种方法都比较费劲。使用Google gflags可以大大简化命令行参数处理。其作用是简化编程时命令行参数的处理,初步使用后感觉十分方便,推荐有兴趣的程序员们使用一下。使用的时候需要包含头文件gflags.h。在使用命令行参数的文件文件中(源文件或头文件),首先使用一下定义语句进行变量的定义:DEFIN

2017-09-06 11:45:46 442

转载 gflags命令行参数

写服务程序时,如果需要提供命令行参数。传统的方法是手工解析argv参数,或者使用getopt函数。两种方法都比较费劲。使用Google gflags可以大大简化命令行参数处理。其作用是简化编程时命令行参数的处理,初步使用后感觉十分方便,推荐有兴趣的程序员们使用一下。使用的时候需要包含头文件gflags.h。在使用命令行参数的文件文件中(源文件或头文件),首先使用一下定义语句进行变量的定义:DEFIN

2017-09-06 11:45:18 491

转载 C++中如何设置前置声明

转载自 http://www.cnblogs.com/alaigle/archive/2012/06/05/2536610.html在编写C++程序的时候,偶尔需要用到前置声明(Forward declaration)。下面的程序中,带注释的那行就是类B的前置说明。这是必须的,因为类A中用到了类B,而类B的声明出现在类A的后面。如果没有类B的前置说明,下面的程序将不同通过编译,编译器将会给出类似“缺

2017-09-05 14:53:37 2798

空空如也

空空如也

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

TA关注的人

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