摘要: macOS开发mysql client的时候,默认开启了沙箱机制。结果每次连接都给报这个错 如果没有捕获好的话,可能只会出现 connect(descriptor:addr:size:): 这个错误 找半天才在网上找到有这个说法的 另外一个是如果要通过调用 ssh启动通道来做跳板访问的话,或者需要访 阅读全文
posted @ 2023-06-01 13:25 gabin 阅读(9) 评论(0) 推荐(0) 编辑
摘要: import SwiftUI final class Box<T> : ObservableObject { // 这个注解不加,那就玩死了也不会更新视图 @Published var val: T init(val: T) { self.val = val } } struct StarRatin 阅读全文
posted @ 2023-06-01 12:10 gabin 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 题目解析: 单链表 A.next->B B.next->C C.next->D D.next->E A->B->C->D->E 反转后 E->D->C->B->A 手动反转 1、B.next=A 2、C.next=B 3、D.next=C 4、E.next=D 5、A.next=null 6、返回E 阅读全文
posted @ 2022-03-04 12:07 gabin 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 1、什么叫局部最小值 局部指的是左 中 右 最小值,自然是三个值做比较取最小了 边界场景:索引0和索引1,这个场景下,如果是判断索引0位置是否最小值的话,此时只需要2个数相比。同理,最后一个数组元素也是2值相比 2、这道算法题其实还有个前提,就是相邻数不等,也就是说,不会出现 1 2 2这样的数组 阅读全文
posted @ 2022-03-02 14:40 gabin 阅读(165) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { for (int i = 0; i < 10; i++) { test(); } } private static void test() { // 1、获取一个有序数组 int i = ThreadLocalRand 阅读全文
posted @ 2022-03-02 12:14 gabin 阅读(63) 评论(0) 推荐(0) 编辑
摘要: public static void main(String[] args) { for (int i = 0; i < 10; i++) { test(); } } private static void test() { // 1、获取一个有序数组 int i = ThreadLocalRand 阅读全文
posted @ 2022-03-02 09:56 gabin 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 1、函数不等概率返回0和1 2、调用2次, 结果 00 11 01 10 3、01和10,只是调换了顺序,概率应该是一样的 4、所以除了01好10,其他情况重做 5、代码验证 原函数 public static int sourceFunc() { return Math.random() > 0. 阅读全文
posted @ 2022-02-28 11:29 gabin 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 1、1~5随机函数 public static int sourceFunc() { return (int) (Math.random() * 5) + 1; } 2、将原函数转化为[0,1]返回值的函数 public static int tmpFunc() { int i = sourceFu 阅读全文
posted @ 2022-02-28 09:59 gabin 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 1、先证明随机数出现0~X的概率是X public static void main(String[] args) { for (int i = 1; i < 10; i++) { test(i / 10d); } } public static void test(double x) { int 阅读全文
posted @ 2022-02-28 09:21 gabin 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1、选择排序 参考算法:每一轮循环都选择出当前范围最大值,然后从右到左开始占位存储 第一轮循环 1)从数组0~N中选择出最大,与索引位0的数进行交换。 第二轮循环 1)从数组中1~N选择出最大,与索引位1的数进行交换。 2)…… 第N-1轮循环 3)从数组N-1~N中选择出最大,与索引位N-1的数进 阅读全文
posted @ 2022-02-24 11:47 gabin 阅读(613) 评论(0) 推荐(0) 编辑