Algorithm
LeetCode算法题
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123 Output: 321 Example 2:
Input: -123 Output: -321 Example 3:
Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
Java 程序实现
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Solution {
public int reverse(int x) {
if (x == 0) {
return x;
}
boolean minus = false;
if (x < 0) {
minus = true;
x = -x;
}
long r = 0;
while (x > 0) {
r = r * 10 + x % 10;
x = x / 10;
}
if (r > Integer.MAX_VALUE) {
return 0;
} else {
return (int) (minus ? -r : r);
}
}
}
Review
Real-time Attention Based Look-alike Model for Recommender System “看一看”推荐模型揭秘:微信团队提出实时 Look-alike 算法,解决推荐系统多样性问题
- 咨询信息的马太效应,强者愈强,弱者愈弱
- quality & diversity,增加推荐内容的质量与多样性
- K-means Algorithm
- Adam Optimizer
- Look-alike 是广告领域经典的推荐算法,拥有定向能力强、用户扩展精准等优点。微信看一看的推荐场景下对传统 look-alike 进行了改造,使之更适合高时效性的资讯推荐系统。
- colllaborative filtering 协同过滤
Tip
未加验证的系统更新,就是耍流氓;系统更新后,测试验证观察15~30分钟;数学是保证,数据是验证。