Share Three questions for today's interview

Source: Internet
Author: User
Share the three questions about today's interview. I. simulate poker licensing. There are 52 cards. we will give them numbers from 1, 2, 3... 52. A total of 52 cards. Use arrays to load these cards and then disrupt the sequential output. For example, 18, 21... 3. 2. the company wants to work with QQ to provide interfaces to QQ. Q will be sent to share the three questions for today's interview
The company name is not mentioned.

I. simulate poker licensing. There are 52 cards. we will give them numbers from 1, 2, 3... 52. A total of 52 cards. Use arrays to load these cards and then disrupt the sequential output. For example, 18, 21... 3.


2. the company will cooperate with QQ to provide interfaces to QQ and send a QQ number. Check QQ's rules. For example, 4323254, the rule is ABAB. 5723723. The rule is ABCABC.


3. if we want to record how many times each flash game on the website has been played, each game is on a separate page.
(A) how can I record data when playing these games?
(B) how many times has a game been played? (If you are using a database, write an SQL statement)


I did not answer the second question. Ask how to implement that requirement.

The number of questions is not bad. there are only three questions, but these questions seem to be not targeted, which is much better than the ones that require two hours of writing.
------ Solution --------------------
The second question:
For each qq, determine the qq prefix and suffix. The length of the tree ranges from 0 to strlen/2.
For example, 4323254
Index 0:
1-bit prefix: 4, with a suffix of 3
2-digit prefix: 43 suffixes 23
3-bit prefix: 432 suffix 325
...

Index 1:
2 prefix 32 suffix 32 equal

Calculate the maximum length.
$qqNs = array("4323254","22222","5123123","23412341234","2222222");
$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

foreach($qqNs as $tmp){
$max = 1;
$qq = $tmp;
while($qq){
for($i=1,$n = floor((strlen($qq)/2));$i <= $n;$i++){
$preTree = substr($qq, 0, $i);
$postTree = substr($qq,$i,$i);
if($preTree == $postTree){
if($i>=$max){
$max = $i;
}
}
}
$qq = substr($qq,1);
}
echo $tmp.":  ".substr($str,0,$max)."
";

Result:
4323254: AB
22222: AB
5123123: ABC
23412341234: ABCD
2222222: ABC


------ Solution --------------------
Why not? It's all about basic questions. don't feel embarrassed about yourself.
I,
$ar = range(1, 54);
shuffle($ar);
print_r($ar);


II. use regular expressions (since the first question is the foundation, the second question will not have high requirements)
$qq = array('4323254', '5723723');
$p = array('/.*(\d\d)\\1.*/', '/.*(\d\d\d)\\1.*/');
$r = array('ABAB $0', 'ABCABC $0');
$t = preg_replace($p, $r, $qq);
print_r($t);
Array
(
[0] => ABABAB 4323254
[1] => abcabc5723723
)

------ Solution --------------------
Reference:
The company name is not mentioned.

I. simulate poker licensing. There are 52 cards. we will give them numbers from 1, 2, 3... 52. A total of 52 cards. Use arrays to load these cards and then disrupt the sequential output. For example, 18, 21... 3.


2. the company will cooperate with QQ to provide interfaces to QQ and send a QQ number. Check QQ's rules. For example, 4323254, the rule is ABAB. 5723723. The rule is ABCABC.


3. if we want to record how many times each flash game on the website has been played, each game is on a separate page.
(A) how can I record data when playing these games?
(B) how many times has a game been played? (If you are using a database, write an SQL statement)


I did not answer the second question. Ask how to implement that requirement.

The number of questions is not bad. there are only three questions, but these questions seem to be not targeted, which is much better than the ones that require two hours of writing.



What does the second question mean by AB ABC? Why can't I understand
------ Solution --------------------
The third question is the communication between flash and php. it is only necessary to transmit parameters over flash.
------ Solution --------------------
The second question refers to the continuous repeating of numbers, just like the repeating decimal places: 4323254 and 5723723.
Similarly, just a few examples: 8742342398,74914891489134
------ Solution --------------------
Reference:
What is "only fixed numbers can be entered "?

Quote: reference:

This can only be done by a fixed number. if it is not fixed, it cannot be done.

For example, if you use another 222222 number in your regular expression, it is not correct. it is impossible to add a rule to a number.
------ Solution --------------------
Third, you can request a php page at the beginning of the game and send the message to the php page. the php page then records the player's information, such as ID, nickname, and time. You can also establish a connection with the server service directly on the flash end using the socket method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.