leetcode-完全二叉树节点个数

摘要: 给定一颗完全二叉树,求节点个数: https://leetcode-cn.com/problems/count-complete-tree-nodes/ 简单粗暴的递归 /** * Definition for a binary tree node. * public class TreeNode 阅读全文
posted @ 2020-11-24 09:20 caffebabe 阅读(67) 评论(0) 推荐(0) 编辑

sql-备忘-指更新为null的记录

摘要: SELECT serial_no, MAX( setup_date ) setup_date, MAX( liquidate_date ) liquidate_date, MAX( expire_date ) expire_date FROM ( SELECT t1.serial_no, IFNUL 阅读全文
posted @ 2020-11-19 17:31 caffebabe 阅读(47) 评论(0) 推荐(0) 编辑

springboot mvc 统一错误处理

摘要: 统一返回结果: package com.caffebabe.codelife.controller; import com.caffebabe.codelife.util.ErrorEnum; import com.caffebabe.codelife.util.UniformException; 阅读全文
posted @ 2020-11-10 21:14 caffebabe 阅读(140) 评论(0) 推荐(0) 编辑

go入门练习006:struct

摘要: struct基本概念 定义:字段顺序非常重要!两个字段完全一样,但顺序不同的struct视为不同。 type Employee struct { ID int Name string Address string DoB time.Time Position string Salary int Ma 阅读全文
posted @ 2020-10-23 11:38 caffebabe 阅读(102) 评论(0) 推荐(0) 编辑

go入门练习005:map

摘要: map基本知识点 创建map: ages := make(map[string]int) // mapping from strings to ints ages := map[string]int{ "alice": 31, "charlie": 34, } ages := make(map[st 阅读全文
posted @ 2020-10-23 10:18 caffebabe 阅读(111) 评论(0) 推荐(0) 编辑

cafebabe go入门练习004:数组和切片

摘要: 数组 数组是固定长度的特定类型元素的序列。数组的大小是数组定义的一部分,所以两个大小不同的数组是两个不同的类型,当然也不能比较。 数组的定义方式: func main() { var a [3]int b := [3]int{1, 2, 3} c := [...]int{1, 2, 3} d := 阅读全文
posted @ 2020-10-23 09:22 caffebabe 阅读(53) 评论(0) 推荐(0) 编辑

cafebabe go入门练习003:常量与iota

摘要: 知识点 常量的值在编译时就已知,常量的底层类型是基本类型boolean,string或number。 常量定义格式: const ( e = 2.71828182845904523536028747135266249775724709369995957496696763 pi = 3.1415926 阅读全文
posted @ 2020-10-22 10:27 caffebabe 阅读(82) 评论(0) 推荐(0) 编辑

go入门练习002:查找重复的行

摘要: 读取标准输入 go的标准输入是os.Stdin,可以用bufio包下的 Scanner来读取。Scanner的Scan()方法每次读取一行,去掉结尾的换行符,然后可以用Text()方法获取这一行。 标准输入结束的默认动作是ctrl+C,这时Scan()方法没有扫描到输入行,返回false。 下面程序 阅读全文
posted @ 2020-10-21 11:20 caffebabe 阅读(149) 评论(0) 推荐(0) 编辑

go入门练习001:打印命令行输入

摘要: 知识点 go入门练习,os包的Args包含了命令行参数,它是一个string切片,Args[0]表示命令本身,其后为命令行参数。 for循环方式 go的for循环基本格式: for initialization; condition; post { // zero or more statement 阅读全文
posted @ 2020-10-21 10:25 caffebabe 阅读(120) 评论(0) 推荐(0) 编辑

go入门-002-程序结构

摘要: 命名 Go命名规则与其他语言类似:字母或下划线开头,后面可以跟字母、数字和下划线;大小写敏感;不能与保留字冲突。 Go有25个关键字: break default func interface select case defer go map struct chan else goto packag 阅读全文
posted @ 2020-08-24 10:43 caffebabe 阅读(178) 评论(0) 推荐(0) 编辑