自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 【Golang】JSON Marshal & Unmarshal

json.Marshal(v interface{}) ([]byte, error)如果传入的v是一个 reference,则直接进行 marshal如果传入的v是一个 pointer,则会将 pointer 中的内容解析,再进行marshaljson.Unmarshal(data []byte, v interface{}) error如果传入的v是一个 reference,则匹配相应的字段来进行 unmarshal如果传入的v是一个 pointer,则会报错:json: Unmarsh

2020-08-17 13:14:04 1088

原创 459. Repeated Substring Pattern[Easy]

DescriptionGiven a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of low...

2019-11-22 13:00:40 153

原创 72. Edit Distance[Hard]

DescriptionGiven two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDele...

2019-11-14 14:46:37 120

原创 448. Find All Numbers Disappeared in an Array[Easy]

DescriptionGiven 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 a...

2019-11-12 15:15:49 111

原创 【Java】HashMap

HashMap是基于哈希表中的Map接口的实现,主要用于存储映射关系,其中key和value允许存储为null值和null键。该类不保证映射的顺序,并且该类是非线程安全的。HashMap最基础的结构是数组+链表,数组的作用是为了能够迅速找到key值所对应的位置,因为数组的查找操作时间复杂度是O(1),而如果是链表的话,会达到O(N)。链表的作用是为了让插入和删除能够更高效地进行,因为插入和删除操...

2019-11-04 11:29:43 90

原创 【Leetcode】Power of N

在Leetcode上发现了三个很有趣的Power of N的题,分别是判断一个数是否是2、3、4的n次幂。在第一次刷题的时候,全部采用的都是将数字num转换为n进制,然后判断该进制是否为1个1加上x个0的形式,从而得到结果。在第二次刷题的时候,特别注意了Follow up: Could you do it without using any loop / recursion?,从而开始思考怎么...

2019-11-03 15:02:21 148

原创 【操作系统】不同的锁

本文参考文章《一句话撸完重量级锁、自旋锁、轻量级锁、偏向锁、悲观、乐观锁等各种锁 ---- 不看后悔系列》和《什么是CAS机制?》,以自己的理解进行总结。操作系统中的锁主要分为两大类:乐观锁和悲观锁。文章目录悲观锁重量级锁自旋锁自适应自旋锁乐观锁CAS机制轻量级锁偏向锁总结悲观锁悲观锁,Pessimistic Lock,即这种锁的“想法”很悲观——方法执行如果不加锁就会出事,所以操作必须上...

2019-11-01 15:14:14 887

原创 【操作系统】进程间通信方式

此次总结来自于文章《记一次面试:进程之间究竟有哪些通信方式?》,从而真正理解了这些通信方式的区别及优缺点,以下是根据文章自己所做出的一些理解和总结。首先,进程间的通信方式有:管道、消息队列、共享内存、信号量、Socket。从概念上来看,其实并不难理解,但是为什么会有这些方式,以及这些方式之间的差异性和优缺点,是我在之前所忽略的。1、管道管道的通知机制有些类似于缓存,一个进程将数据存储于缓存当...

2019-10-30 15:05:00 248

原创 【MySQL】日期、时间相关

参考:MySQL:日期函数、时间函数总结now()获得当前日期+时间(date + time)select now();+---------------------+| now() |+---------------------+| 2019-10-29 17:02:59 |+---------------------+1 row in set (0....

2019-10-29 17:24:37 100

原创 【MySQL】MySQL8忘记密码强制修改(MAC)

1、打开Terminal,使用以下命令,从而使得可以无密码登陆MySQL。mysqld -skip-grant-tables;2、再打开一个Terminal,使用以下命令,无密码登陆MySQL。mysql -u root3、使用以下命令,清空旧密码。mysql> use mysql;mysql> update user set authentication_string...

2019-10-29 17:00:10 608

原创 32位和64位的区别

在C语言中,分配内存使用malloc()函数。现在有一个7GB的数据库需要进行排序,64位的软件可以malloc一个7GB的空间,将整个数据库“放入”内存,然后使用任意排序算法。而32位的软件在malloc时就会out of memory。对于32位系统而言,只能同时操作0~232-1共232字节的内存,也就是4G内存(地址空间)。对于32位系统而言,理论上可以操作264字节的内存,实际情况...

2019-10-15 23:13:23 386

原创 【Java】Overload & Override

Overload重载,函数重载是一个类中声明了多个同名的方法,但有不同的参数个数和参数类型。Override重写,函数重写是在子类中声明与父类同名的方法,从而覆盖了父类的方法。重构解决了子类与父类的差异问题。比较OverloadOverride发生条件同一类下子类继承父类函数名必须相同必须相同传入参数参数类型、个数、顺序至少有一项不同必须相同...

2019-10-09 15:18:54 112

原创 【Java】线程实现方法

Java中,线程的实现有三种方法:继承Thread类,实现Runnable接口,实现Callable接口。extends Threadpublic class ThreadDemo1 { public static void main(String[] args) { Thread t1 = new MyThread(); t1.start(); }}class MyThre...

2019-10-08 13:49:14 98

原创 【Leetcode】210. Course Schedule II[Medium]

DescriptionThere are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expresse...

2019-10-05 14:54:23 102

原创 【Leetcode】207. Course Schedule[Medium]

DescriptionThere are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expresse...

2019-10-05 14:25:33 109

原创 【Leetcode】124. Binary Tree Maximum Path Sum[Hard]

DescriptionGiven a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-chil...

2019-10-04 21:43:35 122

原创 【Java】基本数据类型和包装类

文章目录基本数据类型包装类包装类特性功能丰富可定义泛型类型参数序列化类型转换高频区间的数据缓存注意事项基本数据类型布尔型:boolean整数型:byte(8)、short(16)、int(32)、long(64)浮点型:float(32)、double(64)字符型:char(16)数据类型代表含义默认值取值包装类大小(位)boolean布尔型fal...

2019-09-28 15:13:50 389

原创 【Java】Spring入门

相关课程:Spring入门篇——moocer文章目录第一章 概述1-1 Spring入门课程简介课程包含内容如何学习Spring资源1-2 Spring概况Spring作用适用范围1-3 Spring框架什么是框架为什么使用框架第二章 Spring IoC容器接口及面向接口编程接口面向接口编程什么是IoCSpring的Bean配置Bean的初始化Spring注入设值注入构造注入第三章 Sprin...

2019-09-26 22:54:53 1642

原创 【Leetcode】238. Product of Array Except Self[Medium]

DescriptionGiven an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Note: Please solve it with...

2019-09-26 16:38:39 89

原创 【Java】单例模式

参考文章:Java单例模式——并非看起来那么简单单例(Singleton)模式在Java中是一种广泛使用的设计模式。其主要是为了保证在Java程序中,某个类只有一个实例存在,从而减少每次创建对象的时间开销,同时节约内存空间。与此同时,它还能够避免由于操作多个实例而导致的逻辑错误。单例模式应用的场景一般发生在以下条件下:1、资源共享的情况下,避免由于资源操作时导致的性能或损耗等。如日志文件、应...

2019-09-23 16:01:13 99

原创 【Java】static关键字

文章目录四种用法1、修饰成员变量2、修饰成员方法3、静态块4、静态导包总结初始化顺序四种用法Java中的static关键字有四种用法:修饰成员变量,修饰成员方法,静态块,静态导包。1、修饰成员变量给属性增加static关键字,则对象不再拥有该属性,属性会统一交给类处理。即让对象共享属性。但是这样会让该属性变得难以控制,因为其在任何地方都有可能被修改。2、修饰成员方法static修饰成员...

2019-09-23 15:27:16 89

原创 【Leetcode】621. Task Scheduler[Medium]

DescriptionGiven a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each...

2019-09-17 15:27:41 95

原创 【Leetcode】300. Longest Increasing Subsequence[Medium]

DescriptionGiven an unsorted array of integers, find the length of longest increasing subsequence.Note:There may be more than one LIS combination, it is only necessary for you to return the length...

2019-09-11 16:59:16 141

原创 【Leetcode】322. Coin Change[Medium]

DescriptionYou are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amou...

2019-09-11 14:59:17 121

原创 【Leetcode】33. Search in Rotated Sorted Array[Medium]

DescriptionSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search....

2019-09-11 11:24:19 107

原创 【Leetcode】162. Find Peak Element[Medium]

DescriptionA peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multi...

2019-09-08 14:59:46 189

原创 【Leetcode】347. Top K Frequent Elements[Medium]

DescriptionGiven a non-empty array of integers, return the k most frequent elements.ExampleExample 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [...

2019-09-07 22:50:09 115

原创 【Leetcode】79. Word Search[Medium]

DescriptionGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or v...

2019-09-07 14:52:03 103

原创 【Leetcode】230. Kth Smallest Element in a BST[Medium]

DescriptionGiven a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.ExampleExample 1:In...

2019-09-07 13:32:22 77

原创 【Leetcode】160. Intersection of Two Linked Lists[Easy]

DescriptionWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1->a2->c1->c2->c3B: b1->b...

2019-09-07 00:16:07 82

原创 【Leetcode】73. Set Matrix Zeroes[Medium]

DescriptionGiven a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Follow up:A straight forward solution using O(mn) space is probably a bad idea.A simple imp...

2019-09-06 15:12:49 89

原创 【Leetcode】326. Power of Three[Easy]

DescriptionGiven an integer, write a function to determine if it is a power of three.ExampleExample 1:Input: 27Output: trueExample 2:Input: 45Output: falseSolvingConverting the input into ...

2019-09-05 13:18:31 114

原创 【Leetcode】88. Merge Sorted Array[Easy]

DescriptionGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may ...

2019-09-05 12:45:25 86

原创 【Leetcode】98. Validate Binary Search Tree[Medium]

DescriptionGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s...

2019-09-05 11:59:41 169

原创 【Leetcode】371. Sum of Two Integers [Easy]

DescriptionCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.ExampleExample 1:Input: a = 1, b = 2Output: 3Example 2:Input: a = -2, b = 3Output: 1...

2019-09-04 10:58:22 93

原创 【Leetcode】53. Maximum Subarray [Easy]

DescriptionGiven an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.ExampleInput: [-2,1,-3,4,-1,2,1,-5,4],Output: 6E...

2019-09-04 10:57:22 117

原创 【Leetcode】3. Longest Substring Without Repeating Characters [Medium]

DescriptionGiven a string, find the length of the longest substring without repeating characters.ExampleExample1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3...

2019-09-04 10:55:38 94

原创 【Java】反射机制

文章目录Class类的使用动态加载类获取方法信息获取成员变量信息获取构造函数信息方法反射的基本操作通过反射了解集合范型的本质慕课网:反射——Java高级开发必须懂的四大核心类:Class Method Field ConstructorClass类的使用在面向对象的世界里,万事万物皆对象类是对象,类是java.lang.Class类的实例对象(There is a class named...

2019-08-26 15:45:12 118

空空如也

空空如也

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

TA关注的人

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