本人太笨每全做出来。
请大侠给出解答。
1. true or false
给出两个input和output要满足3个要点
1.R only can go right
2.L only can go left
3.R and L can't cross
ie.
Input: R _ _ _ L _ _ R _
output: R L _ _ _ _ _ _ R
return True
[explanation: input L went to left, andinput R went to right become output.]
ie.
Input: R _ _ _ L _ _ R _
output: L R _ _ _ _ _ _ R
return False
(follow up: what ifone cross is allowed, how to solve it)
2.
Find the rate that Teacher didn't catchstudent cheat:
S stands for a student.
The teacher sits in front of the first row:
-------------------------------------------------
Teacher
S1 S2 S3 S4 S5
S6 S7 S8 S9 S10
S11 S12 S13 S14 S15
S16 S17 S18 S19 S20
....
the first-row student got caught rate is 0.9
the second-row student got caught rate is 0.9 / 2
the third-row student got caught rate is0.9 / 4
.....
the first column student got caught rate is 0.5
the second column student got caught rate is 0.5/ 2
the third column student got caught rate is 0.5 / 4
the fourth column student got caught rate is 0.5 / 8
....
Give you a path, find the possibility(rate)that path of students will NOT be caught.
ie.:
1. S1 to S2 caught rate is 0.9.
2. S1 to S3 caught rate is 0.9 * 0.9
3. S4 to S9 caught rate is 0.5
...
what if the path:S1 ->S6 -> S7 -> S12 -> S17?
Write a function to find the student notbeing caught rate for this path.
*/