“You’re speaking our language. Up for a challenge?”

• level 1和level 2的题目十分简单，每个题目会给24–48个小时的做答时间，考的主要是一些基础的编程概念
• level 3会考一些简单的算法，每个题目会给96个小时的做答时间；
• level 4的题目就比较难了，会考一些不常见的算法。

Commander Lambda has had an incredibly successful week: she completed the first test run of her LAMBCHOP doomsday device, she captured six key members of the Bunny Rebellion, and she beat her personal high score in Tetris. To celebrate, she's ordered cake for everyone - even the lowliest of minions! But competition among minions is fierce, and if you don't cut exactly equal slices of cake for everyone, you'll get in big trouble.

The cake is round, and decorated with M&Ms in a circle around the edge. But while the rest of the cake is uniform, the M&Ms are not: there are multiple colors, and every minion must get exactly the same sequence of M&Ms. Commander Lambda hates waste and will not tolerate any leftovers, so you also want to make sure you can serve the entire cake.

To help you best cut the cake, you have turned the sequence of colors of the M&Ms on the cake into a string: each possible letter (between a and z) corresponds to a unique color, and the sequence of M&Ms is given clockwise (the decorations form a circle around the outer edge of the cake).

Write a function called solution(s) that, given a non-empty string less than 200 characters in length describing the sequence of M&Ms, returns the maximum number of equal parts that can be cut from the cake without leaving any leftovers.

```def solution(s):
sub = s[0:len(set(s))]
return(s.count(sub))
print(solution('abcabcabcabc'))
>> 4
print(solution('abccbaabccba'))
>> 2
```

```def solution(s):
if (len(s) % 2 != 0):
print('Odd')
else:
print('Even')

solution('abcabcN')
>> ODD
solution('abcabc')
>> EVEN
```

• 取余运算 在计算商值时 商值向0方向舍入；靠近0原则
• 取模运算 在计算商值时 商值向负无穷方向舍入；尽可能让商值小的原则(不超多商值的最大值)

## 3、总计算模/余数：a mod b = a - b[a/b] ([a/b]表示整数商)

```def solution(s):
print('INPUT:' + s)
i = (s+s).find(s,1, -1)
sub = s[:i]
print('Substring:', sub)

solution('abccbaabccba')
>> INPUT:abccbaabccba
>> Substring: abccba

solution('xyztxyztxyzt')
>> INPUT:xyztxyztxyzt
>> Substring: xyzt
```

```def solution(s):
print('INPUT:' + s)
i = (s+s).find(s,1, -1)
sub = s[:i]
print("i:", i)
print('Substring_1:', sub)
s2 = s
s2 = s2[:-1]
sub2 = s2[0:len(set(s2))]
print('Substring_2:' +  sub2)

solution('wewewe')
>> INPUT:wewewe
>> i: 2
>> Substring_1: we
>> Substring_2:we

solution('weweweT')
>> INPUT:weweweT
>> i: -1
>> Substring_1: wewewe
>> Substring_2:we
```

find()方法从字符串中找出某个子字符串第一个匹配项的索引位置，该方法与index()方法一样，只不过如果子字符串不在字符串中不会报异常，而是返回-1。

```S.find(sub[,start=0[,end=len(S)]])
```
• sub -- 指定检索的子字符串
• S -- 父字符串
• start -- 可选参数，开始索引，默认为0。（可单独指定）
• end -- 可选参数，结束索引，默认为字符串的长度。（不能单独指定）

```quote = 'Let it be, let it be, let it be'
result = quote.find('let it')
print("Substring 'let it':", result)

Substring 'let it': 11
```

```if len(set(s)) == 1:
```

```def solution(s):
print('-------')
print('INPUT:' + s)
i = (s+s).find(s, 1, -1)
print (i)

if (len(s) % 2 != 0):
print('ODD')
if(len(set(s)) == 1):
print("CASE: ODD SINGLE CHARACTER")
print('pattern:' +  (s[0]))
print('Divisions:' + str(len(s)))
return
else:
s = s[:-1]
if len(set(s)) == 1:
print('pattern:' +  (s[0]))
print("CASE: ODD SINGLE CHARACTER EXTRA CHARACTER")
print('Divisions:' + str(len(s)))
return
elif i == -1:
sub = s[0:len(set(s))]
print('pattern:' +  sub)
print('Divisions:' + str(s.count(sub)))
print("CASE: MULTI CHARACTER EXTRA CHARACTER")
return
else:
sub = s[:i]
print('pattern:' +  sub)
print('Divisions:' + str(s.count(sub)))
print("CASE: ODD MULTI CHARACTER")
return
else:
print('EVEN')
if len(set(s)) == 1:
print('pattern:' +  (s[0]))
print('Divisions:' + str(len(s)))
print("CASE: EVEN SINGLE CHARACTER")
return
else:
sub = s[:i]
print('pattern:' +  sub)
print('Divisions:' + str(s.count(sub)))
print("CASE: EVEN MULTI CHARACTER")
return
```

```solution('a')
solution('aa')
solution('abcabc')
solution('abcabcabc')
solution('aaT')
solution('ababT')
```

```------
INPUT:a
-1
ODD
CASE: ODD SINGLE CHARACTER
pattern:a
Divisions:1
-------
INPUT:aa
1
EVEN
pattern:a
Divisions:2
CASE: EVEN SINGLE CHARACTER
-------
INPUT:abcabc
3
EVEN
pattern:abc
Divisions:2
CASE: EVEN MULTI CHARACTER
-------
INPUT:abcabcabc
3
ODD
pattern:abc
Divisions:2
CASE: ODD MULTI CHARACTER
-------
INPUT:aaT
-1
ODD
pattern:a
CASE: ODD SINGLE CHARACTER EXTRA CHARACTER
Divisions:2
-------
INPUT:ababT
-1
ODD
pattern:ab
Divisions:2
CASE: MULTI CHARACTER EXTRA CHARACTER
```

https://stackoverflow.com/questions/29481088/how-can-i-tell-if-a-string-repeats-itself-in-python

• 了解个人情况
• 一些关于计算机基础知识的题目

SRE 岗 5 轮面试大致考查如下方向：

• Coding & Algorithm
• System Design
• Troubleshooting
• Networking
• Linux/UNIX system

## 总结一下

1、1 轮 foo.bar，2.5 轮电话面试，5 轮 onsite 面试，持续 4 个月，总体耗时 3–4 周。

2、整个应聘的流程，至少接触了 4 位 recruiter，8 个面试官，2 个第三方服务者，算上人力的时间成本，加上 onsite 的机票酒店餐饮签证成本，最后再考虑下 onsite 的通过率，估计 Google 要招聘到一个合格的员工，成本至少是在十万人民币级别的。可见顶尖的人才是相当昂贵的，这还仅仅只是招聘成本。

3、就现在的 IT 技术招聘体制而言，大多数公司采用的无非就是在一定的时间和资源限制下，解决一些面试官心中有明确标准答案的 puzzles——但是这种选拔真得能很好的反应一个面试者在实际工作中的能力么？值得探讨···

4、你要知道，改善随着时间的推移，你的领域知识（语言和问题本身）和你的回答会变得更好。如果你不能在一开始就不能很好地理解题目，也不能快速地想出一个很好的解决方案，不要气馁，总有量变到质变的那一刻，你会感受到的！

0 条评论

• ### 【Python进阶，一学就会】系列1（文末免费送10本书）

列表推导式（list comprehension）为for循环提供了一个简短且更好的选择。它用于我们需要对列表中的每一个元素执行操作的迭代过程中。

• ### 七步理解深度学习

原文链接请点击阅读原文。 There are many deep learning resources freely available online,but...

• ### 第2课 python数据类型与转换

是的，我们主要是3类数据 类型。。 3者之间可以转换，但是有条件，我们先一个个说吧。

• ### 聊聊 print 的前世今生

上周，我翻译了一篇文章，解释了为什么 Python 3 把 print 改为函数？ 概括有如下几点原因：1、print 不适宜作为应用程序级的语句。2、改为一个...

• ### Python教程（三）：基础数据类型

Python中的变量不需要声明。每个变量在使用前都必须赋值，变量赋值以后该变量才会被创建。

• ### 1.Python函数的初识

大家都有没有玩过陌陌，探探这种软件？这种软件是专门为你们没有对象的男士设置的，这是一款合理合法的约炮，哦不对，交友软件，那么现在我们用Python代码简单模拟一...