![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
GoLang
燃烧的冷水
这个作者很懒,什么都没留下…
展开
-
[LeetCode] Longest Palindromic Substring
题目链接:https://leetcode.com/problems/longest-palindromic-substring/description:Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.pa...原创 2019-07-14 18:52:02 · 77 阅读 · 0 评论 -
使用gorm时,主键为空值时遇到的问题
问题描述:最近在使用gorm时,发现db文件在某些情况下会多出来几行重复的数据。type Sip struct { SipPoolID uint Sip string `json:"-" gorm:"primary_key"` NetSegment string `json:"-" gorm:"primary_key"`}使用以上结构体,通过gorm创建出来的表会出现如下情况...原创 2019-07-14 21:38:09 · 2752 阅读 · 0 评论 -
[Tips] go语言中的空struct
参考:https://dave.cheney.net/2014/03/25/the-empty-struct#comment-2815tips:空struct的宽度为0; 不同的空struct,有相同的地址(https://golang.org/ref/spec#Size_and_alignment_guarantees)type s struct {}type ss stru...原创 2019-07-21 17:22:29 · 119 阅读 · 0 评论 -
[LeetCode] ZigZag Conversion
题目链接:https://leetcode.com/problems/zigzag-conversion/submissions/思路:假设最后一个顶点总是在上面的,会有如下两种情况:func convert(s string, numRows int) string { if 1 == numRows { return s } bytes := []byte(s...原创 2019-07-21 22:02:57 · 86 阅读 · 0 评论 -
[LeetCode] Container With Most Water
题目链接:https://leetcode.com/problems/container-with-most-water/一开始我采用了遍历对比了每个可能的面积,后来参考了题目里给出的解决思路:面积由距离和高度决定,而两个指定点之间的面积大小由矮的那个点决定,所以,先算出距离最长的两个点之间的面积。假设高的点b在最右端,这时如果把点b往左移动,面积是只可能变小,因为距离变小,而面积由矮的点...原创 2019-07-28 17:30:23 · 116 阅读 · 0 评论