左耳听风 ARTS Week3
Algorithm
每周至少做一个 Leetcode 的算法题。
integer-to-roman
class Solution {
public String intToRoman(int num) {
int[] values = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
String[] strs = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
StringBuilder sb = new StringBuilder();
for(int i=0;i<values.length;i++) {
while(num >= values[i]) {
num -= values[i];
sb.append(strs[i]);
}
}
return sb.toString();
}
}
最简单的方式就是暴力破解;直接将各种可能用数组列出来;因为最大值是3999;当然这种性能不是太好;
public String intToRoman(int num) {
String M[] = {"", "M", "MM", "MMM"};//0,1000,2000,3000
String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};//0,100,200,300...
String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};//0,10,20,30...
String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};//0,1,2,3...
return M[num/1000] + C[(num%1000)/100]+ X[(num%100)/10] + I[num%10];
}
Review
阅读并点评至少一篇英文技术文章。
Effective > Productive
Being productive is about occupying your time—filling your schedule to the brim and getting as much as you can. Being effective is about finding more of your time unoccupied and open for other things besides work. Time for leisure, time for family and friends. Or time for doing absolutely nothing.
Yes, it’s perfectly okay to have nothing to do. Or, better yet, nothing worth doing. If you’ve only got three hours of work to do on a given day, then stop. Don’t fill your day with five more just to stay busy or feel productive. Not doing something that isn’t worth doing is a wonderful way to spend your time.
https://world.hey.com/jason/effective-productive-acfa210d
Tip
学习至少一个技术技巧。
最近AI产品频出,豆包,文心一言,天工AI助手等;
也许我们并没有详细学习过AIGC,但是并不妨碍我们使用AI产品,提升开发效率,或者生活质量;
学习prompt
技巧也许是现阶段最重要的事情了;
当新技术出现的时候,去主动尝试是最好的学习方法!
Share
分享一篇有观点和思考的技术文章。
PHP 中 array_walk 与array_map的区别
欢迎关注公-众-号【TaonyDaily】、留言、评论,一起学习。
Don’t reinvent the wheel, library code is there to help.
文章来源:刘俊涛的博客
若有帮助到您,欢迎点赞、转发、支持,您的支持是对我坚持最好的肯定(_)
你要保守你心,胜过保守一切。