Logo ByteGopher
  • English
    中文
Logo Inverted Logo
  • Posts
  • Blog
  • CloudNative
  • Infrastructure
    • TimeSeriesDB
  • Kubernetes
  • Note C
  • Note Go
  • React
  • Tips
  • Nodus
  • Interview
  • Life
  • Linux
Hero Image
「XiaoKr」小氪机器人

https://mp.weixin.qq.com/s/PiVNwsf4adOKBwe92zDE4g

January 1, 0001 Read
Hero Image
「剑指offer」 Go语言版本

编码过程中首先要校验输入数据的合法性。 写代码之前首先想好有哪些测试用例,要提高代码的测试覆盖率。 3. 数组中重复的数字 找出数组中重复的数字。 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。 2 <= n <= 100000 如果使用Map,则时间复杂度为O(n), 空间复杂度为O(n)。题目中的关键信息为长度为n的数组,且所有数字都在0~n-1的范围内,所以可以不用额外开辟空间。 1func findRepeatNumber(nums []int) int { 2 var tmp int 3 for i, v := range nums { 4 if v != i { 5 if nums[v] == v { 6 return v 7 } 8 tmp = nums[v] 9 nums[v] = v 10 nums[i] = tmp 11 } 12 } 13 return -1 14} 15 16// 时间复杂度为O(n),空间复杂读为O(1) 4.

January 1, 0001 Read
Hero Image
「心晴」

永远不要让别人影响你的心晴 学习好的地方, 摒弃坏的地方, 不要被同化 To Be A Nice Person.

January 1, 0001 Read
Hero Image
「算法」贪心算法

例题 【简单】n个活动时间,选择可以参与最多的活动 优先选择结束最早的活动 1package main 2 3import ( 4 "fmt" 5 "sort" 6) 7 8type node struct { 9 startAt int 10 endAt int 11} 12 13var ( 14 total int 15 now int 16 res int 17 nodeList = make([]node, 0) 18) 19 20func main() { 21 _, _ = fmt.Scanf("%d", &total) 22 nodeList = make([]node, total) 23 for i := 0; i < total; i++ { 24 _, _ = fmt.

January 1, 0001 Read
Hero Image
「算法与数据结构」Tree

单链表的查询时间复杂度是O(n) 跳表 树 图 Linked List 是特殊化的Tree Tree 是特殊化的图 斐波那契, 状态树,递归树 状态树空间 决策树空间 二叉树 满二叉树:一个二叉树的所有非叶子节点都存在左右孩子,并且所有叶子节点都在同一层级上。 完全二叉树: 存储结构: 链式存储 1// golang 2type Node struct { 3 Data int64 4 LeftNode *Node 5 RightNode *Node 6} // C++ struct TreeNode{ int val; TreeNode *left; TreeNode *right; TreeNode(int x): val(x), left(NULL), right(NULL){} } 1 23. ```java 3public class TreeNode{ 4 public int val; 5 public TreeNode left,right; 6 public TreeNode(int val){ 7 this.

January 1, 0001 Read
Hero Image
「算法与数据结构」排列组合

组合 1import java.util.*; 2 3public class Mains{ 4 public static List<List<Integer>> resultss = new ArrayList<>(); 5 6 public void combinations(List<Integer> selected, List<Integer> data, int num){ 7 if(num == 0){ 8 resultss.add(new ArrayList<Integer>(selected)); 9 return; 10 } 11 if(data.size() == 0 ){ 12 System.out.print(""); 13 return; 14 } 15 selected.add(data.get(0)); 16 combinations(selected, data.subList(1, data.size()), num -1); 17 selected.remove(data.get(0)); 18 combinations(selected, data.subList(1, data.size()), num ); 19 } 20 public static void main(String[] args) { 21 Mains combin = new Mains(); 22 int[] nums = new int[]{1,2,3,4,5}; 23 combin.

January 1, 0001 Read
Hero Image
「算法与数据结构」排序算法

排序算法 术语说明 稳定:如果a原本在b前面,而a=b,排序之后a仍然在b的前面; 不稳定:如果a原本在b的前面,而a=b,排序之后a可能会出现在b的后面; 内部排序:待排序的数据可以全部放入内存中; 外部排序:待排序数据的数量很大,以致于内存不能一次容纳全部记录,所以在排序过程中需要对外存(磁盘)进行访问; 时间复杂度: 一个算法执行所耗费的时间。 空间复杂度:运行完一个程序所需内存的大小。 排序算法总结 排序算法 平均时间复杂度 最好情况 最坏情况 空间复杂度 排序方式 稳定性 冒泡排序 O(n^2^) O(n) O(n^2^) O(1) In-place 稳定 选择排序 O(n^2^) O(n^2^) O(n^2^) O(1) In-place 不稳定 插入排序 O(n^2^) O(n) O(n^2^) O(1) In-place 稳定 希尔排序 O(n logn) O(nlog^2^n) O(nlog^2^n) O(1) In-place 不稳定 归并排序 O(n logn) O(n logn) O(n logn) O(n) Out-place 稳定 快速排序 O(n logn) O(n logn) O(n^2^) O(n logn) In-place 不稳定 堆排序 O(n logn) O(n logn) O(n logn) O(1) In-place 不稳定 计数排序 O(n+k) O(n+k) O(n+k) O(k) Out-place 稳定 桶排序 O(n+k) O(n+k) O(n^2^) O(n+k) Out-place 稳定 基数排序 O(n*k) O(n*k) O(n*k) O(n+k) Out-place 稳定 n:数据规模;k:“桶"的个数;n-place:占用常数内存,不占用额外内存;Out-place:占用额外内存

January 1, 0001 Read
Hero Image
「算法与数据结构」查找算法

二分查找 1public class BinarySearch{ 2 public static void main(String[] args) { 3 int[] arr = {1,2,3,4,5,6,7,8}; 4 int k = 8; 5 System.out.println(binarySerach(arr, k)); 6 } 7 8 public static int binarySerach(int[] arr, int k){ 9 int a = 0; 10 int b = arr.length; 11 12 while(a < b){ 13 int mid = a+(b-a)/2; 14 if(k < arr[mid]){ 15 b = mid; 16 }else if(k > arr[mid]){ 17 a = mid + 1; 18 }else{ 19 return mid; 20 } 21 } 22 return -1; 23 24 } 25}

January 1, 0001 Read
Hero Image
「算法与数据结构」链表

单向链表 1import java.util.*; 2class Node{ 3 private final int value; 4 private Node next; 5 6 public Node(int value){ 7 this.value = value; 8 this.next = null; 9 } 10 public int getValue(){ 11 return this.value; 12 } 13 public Node getNext(){ 14 return this.next; 15 } 16 public void setNext(Node next){ 17 this.next = next; 18 } 19 20 public static void printLinkedList(Node head){ 21 while(head != null){ 22 System.

January 1, 0001 Read
Hero Image
「网络」网络基础

What is the network layer? Network-to-network connections are what make the Internet possible. The “network layer” is the part of the Internet communications process where these connections occur, by sending packets of data back and forth between different networks, In the 7-layer OSI model, the network layer is layer 3. The Internet Protocol(IP) is one of the main protocols used at this layer, along with several other protocols for routing, resting and encryption.

January 1, 0001 Read
Hero Image
「装机」 ITX A4机箱设计

ITX机箱 详设计一个属于自己的ITX机箱 装机清单 参考链接 ITX机箱图纸参考链接 https://sff.design/1210.html https://sff.design/15201.html ACC X11参考链接 https://item.jd.com/10024295444328.html#crumb-wrap gpp https://www.kyairsoft.com/4-3-desert-warrior-full-marking.html

January 1, 0001 Read
Hero Image
「计算机网络」 计算机网络串讲

网络硬件 双绞线 类型 五类线CAT5 超五类线CAT5e 六类线CAT6 超六类线CATT6e 七类线CAT7 频率带宽 100MHz 100MHz 200MHz 500MHz 600MHz 传输速率 100Mbps 1000Mbps 1000Mbps 1Gbps 10Gbps 最大长度 100m 100m 100m 55m 屏蔽类型 屏蔽/非屏蔽 屏蔽/非屏蔽 屏蔽/非屏蔽 屏蔽/非屏蔽 双层屏蔽 双绞线线序 直通,交叉(主要用于对等设备的通信) 标准 1 2 3 4 5 6 7 8 EIA/TIA 568A 绿白 绿 橙白 蓝 蓝白 橙 棕白 棕 EIA/TIA 568B 橙白 橙 绿白 蓝 蓝白 绿 棕白 棕

January 1, 0001 Read
  • ««
  • «
  • 13
  • 14
  • 15
  • 16
  • 17
  • »
  • »»
Navigation
  • About
  • Skills
  • Recent Posts
  • My Story
Contact me:
  • renqiqiang@outlook.com

Stay up to date with email notification

By entering your email address, you agree to receive the newsletter of this website.

Toha Theme Logo Toha
© 2020-2022 Copyright.
Powered by Hugo Logo