ZhangZhihui's Blog  
上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 78 下一页

2023年10月9日

摘要: Problem: You want to find the shortest path between two nodes on a weighted graph. Solution: Use Dijkstra’s algorithm to find the shortest path betwee 阅读全文
posted @ 2023-10-09 22:42 ZhangZhihuiAAA 阅读(17) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to create a weighted graph data structure. Solution: Create structs for nodes and edges and place them in a Graph struct. Create and 阅读全文
posted @ 2023-10-09 15:57 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to create a min heap data structure. Solution: Wrap a struct around a slice of elements to represent a heap. After each push or pop 阅读全文
posted @ 2023-10-09 15:11 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to create a linked list data structure. Solution: Create an element struct that has a pointer to the next element. Wrap another stru 阅读全文
posted @ 2023-10-09 09:45 ZhangZhihuiAAA 阅读(34) 评论(0) 推荐(0) 编辑

2023年10月8日

摘要: Problem: You want to create a set data structure. Solution: Wrap a struct around a map. Create set functions on the struct. A set is an unordered data 阅读全文
posted @ 2023-10-08 16:28 ZhangZhihuiAAA 阅读(6) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to create a stack data structure. Solution: Wrap a struct around a slice. Create stack functions on the struct. A stack is a last-in 阅读全文
posted @ 2023-10-08 16:11 ZhangZhihuiAAA 阅读(7) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to create a queue data structure. Solution: Wrap a struct around a slice. Create queue functions on the struct. A queue is a first-i 阅读全文
posted @ 2023-10-08 16:00 ZhangZhihuiAAA 阅读(5) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to sort a map by its keys. Solution: Get the keys of the map in a slice and sort that slice. Then, using the sorted slice of keys, i 阅读全文
posted @ 2023-10-08 15:35 ZhangZhihuiAAA 阅读(7) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to sort elements in an array or slice. Solution: For int , float64 , and string arrays or slices you can use sort.Ints , sort.Float6 阅读全文
posted @ 2023-10-08 10:50 ZhangZhihuiAAA 阅读(7) 评论(0) 推荐(0) 编辑
 
摘要: Problem: You want to make arrays and slices safe for concurrent use by multiple goroutines. Solution: Use a mutex from the sync library to safeguard t 阅读全文
posted @ 2023-10-08 10:19 ZhangZhihuiAAA 阅读(8) 评论(0) 推荐(0) 编辑
上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 78 下一页