
算法
明明如月学长
阿里巴巴 资深 Java 研发工程师。《系统掌握大语言模型提示词 - 从理论到实践》小册作者、《解锁大厂思维:剖析《阿里巴巴Java开发手册》》、《再学经典:《EffectiveJava》独家解析》专栏作者、《性能优化方法论》技术电子书作者。热爱技术,喜欢思考,乐于分享。
展开
-
LeetCode 1. Two Sum(数组中和为某数的两个整数的角标数组)
题目地址:https://leetcode.com/problems/two-sum/description/Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would hav...原创 2018-04-17 19:49:31 · 415 阅读 · 0 评论 -
LeetCode 7. Reverse Integer(反转整数)
题目网址:https://leetcode.com/problems/reverse-integer/description/题目要求:Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Exam...原创 2018-04-17 20:21:17 · 482 阅读 · 0 评论 -
LeetCode 9. Palindrome Number (回文字数字)
题目地址:https://leetcode.com/problems/palindrome-number/description/题目要求:Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Inpu...原创 2018-04-18 11:41:06 · 678 阅读 · 0 评论 -
LeetCode 14. Longest Common Prefix 最长公共前缀
地址:https://leetcode.com/problems/longest-common-prefix/description/题目:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empt...翻译 2018-04-20 13:51:39 · 381 阅读 · 0 评论 -
链表反转(递归和非递归方式)的正确姿势
1、背景关于链表的反转,很多资料讲解不够清晰,参考“无鞋童鞋”原文:https://blog.youkuaiyun.com/fx677588/article/details/72357389理解好了很多。2、理论讲解此部分内容引用自“https://blog.youkuaiyun.com/fx677588/article/details/72357389”原文如下: 我们知道迭代是从前往后依次...转载 2019-01-26 00:54:53 · 10516 阅读 · 6 评论 -
一篇文章彻底弄懂Base64编码原理
前半部分为转载,后半部分为自己补充----------------------------转载部分start-----------------------------Base64的由来目前Base64已经成为网络上常见的传输8Bit字节代码的编码方式之一。在做支付系统时,系统之间的报文交互都需要使用Base64对明文进行转码,然后再进行签名或加密,之后再进行(或再次Base64)...原创 2019-04-08 23:28:12 · 7493 阅读 · 0 评论 -
Java面试题之写一个死锁代码片段的正确姿势
1、引言面试的时候可能会让你写一段死锁的代码,其实如果对死锁理解深刻,写出来并不难。其中一个典型场景,就是一个线程持有A锁,然后请求获取B锁。另外一个线程正好相反,持有B锁,等待获取A锁。2、死锁必备的四个条件互斥条件:资源是独占的且排他使用,进程互斥使用资源,即任意时刻一个资源只能给一个进程使用,其他进程若申请一个资源,而该资源被另一进程占有时,则申请者等待直到资源被占有者释放。...原创 2019-04-05 00:52:02 · 2679 阅读 · 1 评论