- 博客(29)
- 收藏
- 关注
原创 多线程笔试题
/** * 两个线程交替输出1--100 * @auther plg * @date 2019/5/12 22:05 */ public class Print implements Runnable { private int num = 1; @Override public void run() { while(true){ synchronized (this){ this.notify();
2022-10-30 11:07:30
237
原创 排序算法(自用)
各类排序算法 比较排序 时间复杂度O(nlogn) ~ O(n^2) 主要有:冒泡排序,选择排序,插入排序,归并排序,堆排序,快速排序等。 冒泡排序 实现:比较相邻的元素。如果第一个比第二个大,就交换它们两个; 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对,这样在最后的元素应该会是最大的数; 针对所有的元素重复以上的步骤,除了最后一个; 重复步骤1~3,直到排序完成。 优点:实现简单,n较小时性能较好 代码: public static void bubbleSort(int[] arr) {
2021-10-13 17:30:58
220
原创 两数之和+LUR
牛客简单题 1.两数之和 使用hashmap解决 public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> m = new HashMap<>(); for (int i = 0; i < nums.length; i++) { if (m.get(target - nums[i]) != null) {
2021-10-11 20:55:44
187
原创 关于二进制的算法
二进制中1的个数 输入一个整数 n ,输出该数32位二进制表示中1的个数。其中负数用补码表示。 public int NumberOf1(int n) { int count=0; while(n!=0){ count++; n=n&(n-1); } return count; } 如果一个整数不为0,那么这个整数至少有一位是1。如果我们把这个整数减1,那么原来处在整数
2021-09-28 09:11:14
474
原创 Duplicate Calculation in Recursion14
Duplicate Calculation in Recursion Memoization is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. (Source: wikipedia
2021-06-30 18:36:31
177
原创 redis笔记整理
NoSql:not noly sql 泛指非关系型数据库 特点:方便扩展 大数据量高性能 数据类型是多样性的,不需事先设计数据库 NoSql四大分类: kv键值对 redis 文档型数据库 列存储数据库 图关系数据库 redis:remote dictionary server远程服务字典 定义:c语言编写,支持网络,可基于内存可持久化的日志型,kv数据库 特性:多样的数据类型 持久化 集群 事务 有16个数据库,默认使用第0个 redis的单线程的,但速度还是快的 redis是将所有的数据全部放在内存
2021-06-29 15:12:50
130
原创 Conclusion12
Conclusion Construct Binary Tree from Inorder and Postorder Traversal Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the
2021-06-25 19:50:05
140
原创 Solve Tree Problems Recursively11
Solve Tree Problems Recursively Maximum Depth of Binary Tree A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. class Solution { int max=0; private void maximum_depth(TreeN
2021-06-15 17:18:14
134
原创 Doubly Linked List09
Doubly Linked List Design Doubly Linked List Design your implementation of the linked list. You can choose to use a singly or doubly linked list. A node in a singly linked list should have two attributes: val and next. val is the value of the current node,
2021-06-10 11:35:53
211
原创 Reverse Linked List08
Reverse Linked List Given the head of a singly linked list, reverse the list, and return the reversed list.
2021-06-10 09:48:31
121
原创 Conclusion
Conclusion Height Checker A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected
2021-05-31 08:27:45
159
原创 in-Place Operations
in-Place Operations Replace Elements with Greatest Element on Right Side public int[] replaceElements(int[] arr) { for (int i=0;i<arr.length;i++){ int Gnum=-1; for (int j=i+1;j<arr.length;j++){ if(arr[j
2021-05-27 12:53:08
181
原创 Searching for Items in an Array
Array Check If N and Its Double Exist Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M). public boolean checkIfExist(int[] arr) { boolean flag=false; for (int a :
2021-05-26 09:45:10
163
原创 Deleting Items Froms an Array
Array Remove Element Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. T
2021-05-25 17:36:09
157
原创 Inserting Items Into an Array
Array Duplicate Zeros Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not written. public void duplicateZeros(int[]
2021-05-24 12:11:56
134
原创 Introduction01
Array Max Consecutive Ones Given a binary array nums, return the maximum number of consecutive 1’s in the array. public int findMaxConsecutiveOnes(int[] nums) { int count = 0; int[] result =new int[nums.length]; int
2021-05-23 16:26:39
182
原创 java容器面试题(自用)
java容器面试题(自用) 1.ArrayList和LinkedList,Vector,Array的区别 1.ArrayList底层数据结构为数组,LinkedList底层数据结构为链表,前者查询效率高,增删效率低,后者查询操作性能比较低 2.Vector是线程安全的,类中有许多synchronized进行修饰,因此,效率较低。空间不足时,可设置增长因子 但其实比较鸡肋,它的两个优点都可被替代。线程安全可使用CopyOnWriteArrayList,集合元素较
2021-05-11 18:54:52
228
原创 mybatis脑图
mybatis脑图 链接:https://mm.edrawsoft.cn/map.html?sharecode=606d9ef13d6532a54969740
2021-04-07 20:01:49
145
原创 js基本笔记
JavaScript 1.运行在客户端的脚本语言 2.组成:ECMAScript,DOM,BOM 3.var是一个JS关键字,用来声明变量 4.js是一种弱类型语言(动态语言) 变量的数据类型是由JS引擎根据=右边变量 值的数据类型来判断的,拥有动态类型,意 味着相同的变量可用作不同的类型 5.简单数据类型 Number:isNaN()判断是否为非数字 String:
2021-04-02 16:50:25
125
原创 java基础脑图
Java基础脑图 网址:https://mm.edrawsoft.cn/map.html?sharecode=6062a385a02fb8a36253060
2021-03-30 12:06:18
122
原创 java.util.Date与java.sql.date与Timestamp与String的转换
java.util.Date与java.sql.date与Timestamp与String的转换 在进行数据库操作时,经常会对java.util.Date与java.sql.Date转换 1.java.util.Date与java.sql.Date 结果 实质为java.util.Date转为long在转为java.sql.Date 实质为java.sql.Date转为long在转为java.util.Date 2.java.util.Date与Timestamp timestamp是java.sql
2021-03-16 20:54:54
340
原创 java-TreeMap
java-TreeMap 问题来源 TreeMap的实现是红黑树算法的实现 1.先了解红黑树 a.红黑树是一颗自平衡的排序二叉树。 b.节点为红色或黑色的平衡二叉树 c.具体规则 d.红黑树的三大操作:左旋,右旋,着色 2.TreeMap数据结构 TreeMap的一个重要属性 比较器 a.如题,构造一个比较器new TreeMap<>();则使用默认的比较器 b.也可new TreeMap<>(Comparator<? super K> comparator);则使
2021-02-10 11:22:56
225
原创 数组的声明与初始化
数组的声明与初始化 问题由来 int[] arrays; // arrays = {1,2}; // arrays = int[2]; // arrays = int[] {1,2}; int[] arr=new int[] {2,3}; 数组arrays声明后,无法进行初始化(或者说是我不知道如何进行初始化,qaq~) 深层剖析 1.初始化分为静态初始化和动态初始化 静态:int[] a = {1,2,3,4,5}; 动态:int[] b=new int[5]; 2.数组一定需要初始化
2020-12-21 10:28:18
1007
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅