楠君的小窝
Lc1753.Maxinum Score From Removing Stone
题目 You are playing a solitaire game with three piles of stones of sizes a, b, and c respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves). Given three integers a, b, and c, return the maximum score you can get. Example 1: Input: a = 2, b = 4, c = 6 Output: 6 Explanation: The starting state is (2, 4, 6). One optimal set of mo ...
LC1760. Minimum Limit of Balls in a Bag
题目 You are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations. You can perform the following operation at most maxOperations times: Take any bag of balls and divide it into two new bags with a positive number of balls. For example, a bag of 5 balls can become two new bags of 1 and 4 balls, or two new bags of 2 and 3 balls. Your penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operation ...
loadimage重载问题
未修改字符集时easyx的loadimage会报错 首先我们来看加载图片loadimage接收哪些参数 1void loadimage(IMAGE *pDstImg, LPCTSTR pImgFile, int nWidth = 0, int nHeight = 0, bool bResize = false); 第一个参数为IMAGE的指针,我们要将IMAGE的地址传入 1IMAGE picture 第二个参数为LPCTSTR,easyx接受Unicode字符集若想要修改,右键解决方案->属性->高级->字符集->使用多字节字符集. 修改以后我们就可以传入指针字符数组 此时就能传入图片所在的地址 第三个和第四个参数传入图片大小即可. 主要就是解决了loadimage报错重载的问题。
append的feature
起因 今天我在刷LeetCode的每日一题,Go我实在不知道怎么写出来,我就看了一眼题解,发现题解解答方式很有意思。它创建了一个byte切片,然后将数字转换成string放进byte切片中. 我很好奇,为什么一个类型为string的值能append进byte切片中 代码 123456789101112131415161718func getLucky(s string, k int) int { //-------------------------------------------------------------------- t := make([]byte, 0, 10) for _, c := range s{ t = append(t, strconv.Itoa(int(c - 'a' + 1))...) } //-------------------------------------------------------------------- digit := st ...
LC.Sum of Digits of String After Convert
题目 You are given a string s consisting of lowercase English letters, and an integer k. First, convert s into an integer by replacing each letter with its position in the alphabet (i.e., replace ‘a’ with 1, ‘b’ with 2, …, ‘z’ with 26). Then, transform the integer by replacing it with the sum of its digits. Repeat the transform operation k times in total. For example, if s = “zbax” and k = 2, then the resulting integer would be 8 by the following operations: Convert: "zbax" ➝ "(26)( ...
Widget常见
隐藏与显示 hide 与 show 方法 1234# 隐藏widgetwidget.hide()# 显示widgetwidget.show() 这两个方法在项目中很有用,当我们按下一个pushbutton的时候,我们可以隐藏一个窗口,打开一个窗口。 最典型的就是登录界面,我们在登录的时候有两种可能: 登录 注册 那么我们要在用户点击其中一个pushbutton的时候打开对应的窗口来满足用户的需求。 自定义Widget样式表失效 使用self.setAttribute(Qt.WA_StyledBackground, True)
1832. Check if the Sentence Is Pangram
题目 A pangram is a sentence where every letter of the English alphabet appears at least once. Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise. Example 1: 123Input: sentence = "thequickbrownfoxjumpsoverthelazydog"Output: trueExplanation: sentence contains at least one of every letter of the English alphabet. Example 2: 12Input: sentence = "leetcode"Output: false Constraints: 1 <= sentence.length < ...
LC1781. Sum of Beauty of All Substrings
前言 从今天开始2022.12.12开始,LeetCode每日一题使用英文读题,主要是为了锻炼自己在英语方面的能力. 接下来LeetCode会暂缓,由于报名了蓝桥杯,我希望自己在蓝桥杯大赛上能有一个好成绩所以得刷一下蓝桥杯的题目. 题目 The beauty of a string is the difference in frequencies between the most frequent and least frequent characters. For example, the beauty of "abaacc" is 3 - 1 = 2. Given a string s, return the sum of beauty of all of its substrings. Example 1: 123Input: s = "aabcb"Output: 5Explanation: The substrings with non-zero beauty are ["aab","aabc" ...
1775. 通过最少操作次数使数组的和相等
题目 给你两个长度可能不等的整数数组 nums1 和 nums2 。两个数组中的所有值都在 1 到 6 之间(包含 1 和 6)。 每次操作中,你可以选择 任意 数组中的任意一个整数,将它变成 1 到 6 之间 任意 的值(包含 1 和 6)。 请你返回使 nums1 中所有数的和与 nums2 中所有数的和相等的最少操作次数。如果无法使两个数组的和相等,请返回 -1 。 示例 1: 输入:nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2] 输出:3 解释:你可以通过 3 次操作使 nums1 中所有数的和与 nums2 中所有数的和相等。以下数组下标都从 0 开始。 将 nums2[0] 变为 6 。 nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2] 。 将 nums1[5] 变为 1 。 nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2] 。 将 nums1[2] 变为 2 。 nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2] ...
工厂函数
工厂函数 个人理解 工厂函数顾名思义就是这个函数像工厂一样生产。一般用于创建自定义的结构体,便于使用者调用 示例 123456789101112131415type person struct{ name string age uint}func NewPerson(name string) *person{ return &person{name: name}}func main(){ User1 := person{name: "JunNanZeng"} User2 := NewPerson("JunNanZeng") // User1 将创建值类型接口和指针类型接口 // User2 只创建指针类型接口} 看似User1和User2一样,实际上返回的不一样,User1创建的person返回的是值,而User2返回的是指针类型*person。 检验 对以上的说法我们可以使用以下的方法进行检验 1 ...
Go的struct和interface
struct struct(结构体)的定义 struct(结构体)是一种聚合类型,里面可以包含任何类型的值,这些值就是我们定义的结构的成员,也称为字段 关键字和声明 type+struct 1234type structName struct{ fieldName typeName ...} 示例 1234type person struct{ name string age uint} 使用 1234567891011121314151617181920type person struct{ name string age uint // 结构体里面值的类型可以是自定义的类型 addr address}type address struct{ province string city string}func main(){ user := person{name: "JunNanZeng", ...
匿名函数与闭包
匿名函数 定义 顾名思义,匿名函数就是没有名字的函数,这是它与正常函数的主要区别 创建 1234567func main() { sum := func(a int, b int) int { return a + b } fmt.Println(sum(10, 20)) // sum(10, 20) -> 30} 有了匿名函数就能在函数中定义函数(函数嵌套) 定义的内部函数也被称为内部函数 可以使用外部函数的变量,也被称为闭包 闭包 1234567891011121314151617func main() { c1 := colsure() fmt.Println(c1()) fmt.Println(c1()) fmt.Println(c1()) // 1 // 2 // 3} func colsure() func() int { i := 0 return func() int { ...
avatar
🐟认真摸鱼中
楠君的小窝
Live is so good
前往小窝
公告栏
--- 主域名 ---
fomal.cc | fomal.cn
--- 备用域名 ---
netlify.fomal.cc
cloudflare.fomal.cc
--- 网站安卓APP ---
🍧点此下载🍧
小站资讯
文章数目 :
111
本站总字数 :
6.3w
本站访客数 :
本站总访问量 :
最后更新时间 :
空降评论复制本文地址
随便逛逛昼夜切换关于博客美化设置切换全屏打印页面