自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

沉浸如海

男儿当自强

  • 博客(45)
  • 问答 (15)
  • 收藏
  • 关注

原创 Seata-TCC快速上手

Seata-TCC快速上手

2022-12-14 00:29:34 628 1

原创 Linux常用指令

sudo su admin一、 lstouch新建文件查看文件权限:ls -l,ll。具体可看修改文件权限:chmod: chmod [{ugoa}{±=}{rwx}] [文件或目录]r:4,w:2,x:1,将file的owner、group、other都改为rwx权限,chmod 777 file或者chmod a+rwx file或者chmod ugo=rwx file,file的...

2019-01-01 21:03:08 218

原创 不可重入锁、可重入锁的实现以及测试

可重入锁定义:线程去请求自己拥有的锁可请求到interface SelfDefineLock{ void lock(); void unlock();}class Father{ SelfDefineLock lock; Father(SelfDefineLock lock){ this.lock = lock; } void do_(){ lock.lock(); ...

2018-04-08 16:43:26 724

原创 Synchronized、lock、volatile、ThreadLocal、原子性总结、Condition

Synchronized、lock、volatile、ThreadLocal、原子性总结、Condition

2017-12-07 21:58:22 3193 4

原创 Majority Element

算法证明见论文,论文节选5.2 The Algorithm Imagine a convention center filled with delegates (Le., voters) each carrying a placard proclaiming the name of his candidate. Suppose a floor fight ensues and delega

2017-03-24 15:39:37 364

原创 2017网易游戏雷火盘古实习生招聘笔试真题 第四题

原题见牛客网 点击打开链接上面的链接不行就用下面的链接链接:https://www.nowcoder.com/questionTerminal/7f107b22d8da4381bf713c0a7c99667a来源:牛客网描述:在一条无限长的跑道上,有N匹马在不同的位置上出发开始赛马。当开始赛马比赛后,所有的马开始以自己的速度一直匀速前进。每匹马的速度都不一样,且全部

2017-03-20 17:06:59 1090

原创 Java IO流

# 字节流:InputStream OutputStream系列 字符流:Reader Writer系列 InputStreamReader(InputStream)采用默认编码表,将字节流按照特定的编码方式读取测试package io流;import java.io.BufferedInputStream;import java.io.IOException;import jav

2017-02-18 16:52:20 505

原创 python四子棋游戏

实验楼上的一门课,改了部分代码,pygame部分只看了程序框架。课程链接,不知道先手是不是有必胜的算法,感觉很难赢AI。#-*-coding:utf-8-*-#!/usr/bin/pythonimport random, copy, sys, pygamefrom pygame.locals import *BOARDWIDTH = 7 # 棋子盘的宽度栏数BOARDHEIG

2017-02-16 20:26:08 7241 3

原创 阻塞、非阻塞、同步、异步

1.阻塞、非阻塞、同步、异步的概念首先要了解用户态和内核态。输入操作分两个阶段: 等待数据准备好 从内核向进程复制数据 对于套接字的输入操作: 等待数据从网络中到达,当分组到达时被复制到内核的某个缓冲区 数据从内核缓冲区复制到应用进程缓冲区 同步、异步的区别在于进程是否需要等待真正的内核IO操作的完成(数据从内核态到用户态的复制),而阻塞、非阻塞的区别在于进...

2017-02-13 11:01:42 366

原创 Can I Win

原题:In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.What if we change the

2016-12-11 15:43:29 401

原创 Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in

2016-12-07 09:39:33 259

原创 链表奇数元素放在偶数元素前面

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNode oddE

2016-12-05 12:17:06 628

原创 sprintf引发的死循环

调用了不安全的sprintf,一开始自信满满觉得反正自己知道源和目的变量的内存,复制过去不会溢出的,所以就用这个不安全的函数吧错误代码:int get_len(char *buffer, int len){ int i = 0; int num = 0; for(i = 0; i < len - 1; ++i){ printf("bei:%d\n",i); char te

2016-12-03 12:09:27 1160

原创 Linux搜索指定文件夹并打开最符合搜索目标名称的文件

先大致参考关于Linux相对路径的问题:http://blog.csdn.net/yongqiangyue/article/details/7707854关于搜索Linux文件目录下文件http://myswirl.blog.163.com/blog/static/513186422010102495152843/open、openat函数参考UNIX环境高级编程和http://blo

2016-11-28 21:51:13 1048

原创 Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.用的KMP算法,时间复杂度O(n+m),建立Next数组的时间复杂度需要仔细观察才能计算出来,参考《算法导论》KMP算法细说起来比较麻烦

2016-11-27 10:35:33 248

原创 Reverse Words in a String

Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in-place in

2016-11-23 11:38:20 286

原创 N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Eac

2016-11-16 15:30:14 310

原创 N-Queens II

原题:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.回溯法代码:public class Solution { boolean able_place(boole

2016-11-16 13:34:40 239

原创 《算法》union&find算法及改进

算法详细内容参考《算法》第4版1.5案例研究:union-find算法分析运行结果:package union;import java.util.Arrays;import java.util.Random;class WeightQuickUnion { private int[] id; //分量id,每个节点所属集合标识 private int[] size; //以该节

2016-11-15 15:25:03 410

原创 Java数组里元素是List

ArrayList name[] = new ArrayList()[];ArrayList[] graph = new ArrayList[10];都不是正确使用方法,正确的是:ArrayList name[] = new ArrayList[9];ArrayList> name= new ArrayList>(/*capacity*/);先记录下错误和解决方

2016-11-13 13:28:25 4855

原创 Word Ladder II

Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord toendWord, such that:Only one letter can be changed at a timeEach

2016-11-12 23:04:22 323

原创 Basic Calculator

Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and em

2016-11-10 21:39:30 287

原创 Construct Binary Tree from Preorder and Inorder Traversal

Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.开始还想着有重复怎么办,后来发现题目给了没有重复数字,如果有重复数字那树可能不唯一,但是假如只有一两个重复数字树还

2016-11-05 19:51:43 288

原创 Binary Tree Inorder Traversal

中序遍历一个二叉树Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note:

2016-11-05 13:12:21 237

原创 Queue Reconstruction by Height

Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of t

2016-10-27 16:13:37 200

原创 java并发学习笔记(二) 测试synchronized锁住对象的范围

假如synchronized了一个对象,而这个对象的成员变量中有另个对象的引用,那么是否同时锁住了那个引用所指的对象?A对象中有对象C的引用,synchronized(this)锁住了A,那么另个调用了对象C的线程还能继续执行吗?测试是可以的,但是不能保证测试代码是正确的。import java.util.concurrent.ExecutorService;import java.

2016-10-26 10:54:42 258

原创 java并发学习笔记(一):wait() notifyAll() 生产者 消费者

一、wait()与notifyAll()参考《thinking in Java》import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.TimeUnit;class Car{ private boolean waxOn

2016-10-24 20:37:56 326

原创 Add Binary

主要拿来练C语言语法,代码不是很好看Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".char* addBinary(char* a, char* b) { char *pa = a; ch

2016-10-23 16:45:01 211

原创 Find the Difference

iven two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was a

2016-10-23 16:41:18 230

原创 3Sum Closest

原题Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have

2016-10-21 20:24:30 207

原创 Wildcard Matching & Regular Expression Matching & KMP

觉得Wildcard Matching & Regular Expression Matching & KMP都是字符串匹配问题,所以想把它们放一起方法有动态规划、回溯、有限自动机一、Wildcard Matching:Implement wildcard pattern matching with support for '?' and '*'.'?' Matches

2016-10-19 16:09:08 498

原创 字符串算法:最长公共子序列、最短编辑距离等

最长公共子序列 编辑距离 最长递增子序列等

2016-10-07 21:25:46 1315

原创 15. 3Sum M

原题:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must no

2016-09-25 21:55:25 192

原创 简单的TCP服务器与客户端

参考《unix 网络编程 卷1》与 点击打开链接需要提前了解:1.协议方面:三次握手建立连接、四次握手断开连接2.通信流程:请参考点击打开链接3.fork()、read()(也可以用recv()函数)、write()(也可以用send()函数)服务器:#include #include #include // read()#include //htonl ht

2016-09-17 22:26:28 351

原创 33. Search in Rotated Sorted Array H

Search in Rotated Sorted Array

2016-09-17 10:29:59 285

原创 85. Maximal Rectangle H

85. Maximal Rectangle

2016-09-15 21:28:27 240

原创 tinyhttpd源码分析

tinyhttpd源码分析

2016-09-14 21:09:50 331

原创 84. Largest Rectangle in Histogram H

Largest Rectangle in Histogram

2016-09-13 21:40:46 274

原创 167. Two Sum II - Input array is sorted M

167. Two Sum II - Input array is sorted M

2016-09-07 21:16:11 219

原创 Java 单例模式 安全问题

Java单例模式 安全

2016-09-07 16:01:39 251

空空如也

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

TA关注的人

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