自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 资源 (1)
  • 收藏
  • 关注

原创 mysql事务

MySQL中的事务事务的实现是基于数据库的存储引擎。不同的存储引擎对事务的支持程度不一样。MySQL中支持事务的存储引擎有innoDB和NDB。innoDB是MySQL默认的存储引擎,默认的隔离级别是RR,并且在RR的隔离级别下更进一步,通过多版本并发控制(MVCC,Multiversion Concurrency Control )解决不可重复读问题,加上间隙锁(也就是并发控制)解决幻读问题。...

2019-06-12 10:44:13 124

原创 remove-duplicates-from-sorted-list and gray-code and reverse-linked-list-ii and remove-duplicates-f

删除链表中重复的结点/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * }...

2019-06-10 10:13:58 117

原创 longest-palindromic-substring

public class Solution { int max=0; int start=0; public String longestPalindrome(String s) { if(s.length()<2){ return s; } for(int i=0;i<s.leng...

2019-06-07 20:14:20 208

原创 binary-tree-zigzag-level-order-traversal

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */import java.util.*;public class ...

2019-06-07 16:24:11 111

原创 convert-sorted-array-to-binary-search-tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * ...

2019-06-04 00:10:19 89

原创 minimum-path-sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at an...

2019-06-03 14:02:10 83

原创 unique-binary-search-trees-ii

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; left = null; right = null; } * } */import...

2019-05-29 17:42:05 141

原创 path-sum

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { publi...

2019-05-29 15:31:58 102

原创 restore-ip-addresses

import java.util.*;public class Solution { public ArrayList<String> restoreIpAddresses(String s) { ArrayList<String> res=new ArrayList<String>(); String temp="";...

2019-05-28 00:26:15 86

原创 add two numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...

2019-05-27 10:40:15 94

原创 interleaving-string

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 =“aabcc”,s2 =“dbbca”,When s3 =“aadbbcbcac”, return true.When s3 =“aadbbbaccc”, return false.pub...

2019-05-26 11:29:10 296

原创 Shifting Letters

We have a string S of lowercase letters, and an integer array shifts.Call the shift of a letter, the next letter in the alphabet, (wrapping around so that ‘z’ becomes ‘a’).For example, shift(‘a’) = ...

2019-05-10 20:18:06 135

原创 Maximize Distance to Closest Person

In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty.There is at least one empty seat, and at least one person sitting.Alex wants to sit in the seat...

2019-05-10 16:06:57 120

原创 顺时针打印矩阵

顺时针打印矩阵import java.util.ArrayList;public class Solution { public ArrayList<Integer> printMatrix(int [][] matrix) { ArrayList<Integer> res=new ArrayList<Integer>(); ...

2019-05-09 16:31:23 93

原创 二叉树转双向链表

输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。public class Solution { private TreeNode leftHead=null; private TreeNode rightHead=null; public TreeNode Convert(TreeNode pRootOfT...

2019-05-09 15:12:12 118

原创 重建二叉树

输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。/** * Definition for binary tree * public class TreeNode { * int val; * ...

2019-05-09 11:07:39 75

原创 leetcode pathSum3

# Definition for a binary tree node.# class TreeNode(object):# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution(object): d...

2019-04-19 21:12:53 172

转载 http和https

https安全套接字层超文本传输协议:https在http的基础上增加了ssl或者TLS协议,ssl依靠证书来验证服务器的的身份,并为服务器和浏览器之间的通信加密https协议的主要作用分为两种,一种是建立安全的信道,另外一种是确认网站的真实性http协议传输的数据都是未加密的,ssl(Secure Socket Layer)协议用于对http协议传输的数据进行加密传输,http和https...

2019-03-28 17:56:51 130

原创 select、epoll、socket

socket()函数:socket函数对应一个普通文件的打开操作,普通文件的打开操作返回一个文件描述符,socket用于创建一个socket描述符,它唯一标识一个socket,socket函数的三个参数分别为:domain,协议族(AF_INET)协议族对应觉决定了socket的地址类型,AF_INET对应ipv4(32位)与端口号(16)的组合type,指定socket类型,常用的有SO...

2019-03-27 21:32:05 129

原创 String、StringBuffer和StringBuilder

String的对象不可变,StringBuffer和StringBuilder是可变的速度:StringBuilder执行速度最佳,StringBuffe次之,String最慢String,StringBuffer是线程安全的,StringBuilder是线程不安全的三个类都是被final修饰的,因此不可继承StringBuilder和StringBuffer有公共父类AbstractS...

2019-03-26 22:17:21 101

转载 tcp为什么3次握手 以及time_wait为什么等待2msl

tcp三次握手:一端(client)A发出去的第一个连接请求报文并没有丢失,而是因为某些未知的原因在某个网络节点上发生滞留,导致延迟到连接释放以后的某个时间才到达另一端(server)B。本来这是一个早已失效的报文段,但是B收到此失效的报文之后,会误认为是A再次发出的一个新的连接请求,于是B端就向A又发出确认报文,表示同意建立连接。如果不采用“三次握手”,那么只要B端发出确认报文就会认为新的连接...

2019-03-26 22:00:37 373

原创 Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclas...

2019-03-26 14:51:07 86

原创 Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume nums1 and num...

2019-03-26 12:06:18 92

原创 合并k个有序链表

# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def mergeKLists(self, lists: List[ListNode]) ...

2019-03-26 11:46:54 160

原创 链表排序

Sort a linked list in O(n log n) time using constant space complexity.# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = ...

2019-03-26 11:40:16 102

原创 MinStack

class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack=[] def push(self, x: int) -> None: if(not self.stack):...

2019-03-26 11:23:03 106

原创 反转链表

/*public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; }}*/public class Solution { public ListNode ReverseList(ListNode head) { ...

2019-03-26 11:13:13 91

原创 Path Sum III

You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it must ...

2019-03-26 11:06:39 94

原创 Hamming distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.class Solution(object): def hammingDistance(self, x, y): """ :ty...

2019-03-26 10:40:31 170

原创 Convert BST to Greater Tree

题目描述:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.I...

2019-03-26 10:36:29 97

原创 HashMap实现原理

HashMap基于Map接口的非同步实现,允许null键和null值此类不保证映射顺序,不保证该顺序永远不变HashMap的数据结构:链表和数组的结合体底层实现是一个数组,数组的每一项就是一个链表,Entry是一个static class,其中包含key、value以及next,它的key和hash是final的HashMap在容量总是2的n次方,h&(length-1)相当于对...

2019-03-25 15:54:48 93

原创 ConcurrentHashMap

ConcurrentHashMap:数组加链表,ConcurrentHashMap 包含一个Segment数组,而Segment是ConcurrentHashMap的内部类,在Segment中柏含一个HashEntry的数组,而HashEntry是ConcurrentHashMap的内部类,HashEntry中包含key和value以及next指针,所以HashEntry可以构成一个链表,通俗的讲...

2019-03-25 11:23:46 126

原创 最小k个数

import java.util.*;public class Solution { public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k) { ArrayList<Integer> list=new ArrayList<Integer>(); ...

2019-03-24 18:22:31 132

原创 字符串价值

import java.util.*;public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int a2z[]=new int[26]; char line[]=sc.nextLine().toCharArr...

2019-03-15 00:16:36 205

原创 数组中数字出现的次数

统计一个数字在排序数组中出现的次数。public class Solution { public int GetNumberOfK(int [] array , int k) { int start=0; int end=array.length-1; if((end==0)&amp;&amp;(k==array[0])) ...

2019-03-14 23:24:54 946

原创 1的个数

输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。public class Solution { public int NumberOf1(int n) { int count=0; while(n!=0){ n=n&amp;(n-1); count++; } r...

2019-03-14 21:16:17 183

原创 volatile不保证原子性

我的理解是,在volatile单独的读和写,都是直接从主内存中读,写入主内存,但是,在volatile i++的时候,另外一个线程假设已经改变了i的值,并写入主内存,并告诉其他线程你们缓存的数据已经失效了,但是本线程已经完成i++,并且不需要再读取i的值,我现在要做的事情是写i。所以我不会再去读取i的最新值。volatile保证的是,在读的时候会从主存中读,在写的时候写入主存。在生成汇编代码时会...

2019-03-13 10:22:39 135

原创 抽象类与接口

抽象类的抽象方法必须全部把子类实现,如果不能全部实现,则子类也必须是抽象类。抽象类可以没有抽象方法一个类中有抽象方法,这个类一定是抽象类抽象类中方法必须全部被实现·,抽象方法不能是静态方法,也不能是private方法接口设计的目的是对类行为的约束,提供一种机制,约束不同的类具有相同的行为,它只约束行为的可有可无,但是不对如何实现进行限制。抽象类除了不能被实例化之外,和普通类一模一样,如...

2019-03-12 19:39:03 125

原创 删除重复字符

牛牛有一个由小写字母组成的字符串s,在s中可能有一些字母重复出现。比如在"banana"中,字母’a’和字母’n’分别出现了三次和两次。但是牛牛不喜欢重复。对于同一个字母,他只想保留第一次出现并删除掉后面出现的字母。请帮助牛牛完成对s的操作import java.util.*;public class Main{ public static void main(String args...

2019-03-11 19:40:52 263

原创 大整数乘法

有两个用字符串表示的非常大的大整数,算出他们的乘积,也是用字符串表示。不能用系统自带的大整数类型。import java.util.*;public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); String ...

2019-03-11 15:25:46 178

人工智能一种现代学方法

人工智能一种现代学方法 课后答案

2018-12-18

空空如也

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

TA关注的人

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