[345] Reverse Vowels of a String
Easy Two Pointers String
Given a string s, reverse only all the vowels in the string and return it.
The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases.
Example 1:
Input: s = "hello"
Output: "holle"
Example 2:
Input: s = "leetcode"
Output: "leotcede"
解答
注意byte与string的互相转换
func reverseVowels(s string) string {
if len(s) <= 1 {
return s
}
b := []byte(s)
begin, end := 0, len(b)-1
for begin < end {
if !isVowel(b[begin]) {
begin++
continue
}
if !isVowel(b[end]) {
end--
continue
}
b[begin], b[end] = b[end], b[begin]
begin++
end--
}
return string(b)
}
func isVowel(c byte) bool {
if c < 'a' {
c += 32
}
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'
}
注意byte与string, byte与rune之间的互相转换
func reverseVowels(s string) string {
if len(s) <= 1 {
return s
}
vowels := "aeiouAEIOU"
vowelMap := make(map[byte]bool)
for _, val := range vowels {
vowelMap[byte(val)] = true
}
b := []byte(s)
begin, end := 0, len(s)-1
for begin < end {
if !vowelMap[b[begin]] {
begin++
continue
}
if !vowelMap[b[end]] {
end--
continue
}
b[begin], b[end] = b[end], b[begin]
begin++
end--
}
return string(b)
}
Rust 是写前端基建,是当下趋势;Rust 语言在前端工具链的影响越来越大
- Rust Is The Future of JavaScript Infrastructure
- Hacker News: Rust Is the Future of JavaScript Infrastructure (leerob.io)
- rust-fe
- Golang has integer types called byte and rune that are aliases for uint8 and int32 data types
- The byte data type represents ASCII characters while the rune data type represents a more broader set of Unicode characters that are encoded in UTF-8 format.
- The default type for character values is rune
-
mvn install:install-file -Dfile=/path/XXX-1.0.0.jar -DgroupId=com.XX -DartifactId=XXX -Dversion=1.0.0 -Dpackaging=jar
-
mvn install:install-file -Dfile=/path/XXX-1.0.0-source.jar -DgroupId=com.XX -DartifactId=XXX -Dversion=1.0.0 -source -Dpackaging=jar
前端从最初的脚手架工具、组件库、持续集成体系、自动化测试、多端适配到现在的全面低代码平台、前端智能化、在线IDE,大前端一直朝着提高生产力,提高研发效能的方向演进。
在D2C解决方案上,目前有以下几种开源方案:CodeFun, imgcook,58 Picasso,具体对比可以参考以下几个附件。可能方案有更多,只是自己刚刚了解这块,待后续学习后补充。通过去这三种方案的相关官网了解,觉得阿里的imgcook在文档,使用教程方面都做的非常不错,特别是关联博客中的智能生成代码2020,2019系列文章,都非常不错,比较容易入门。