< turn >2016 Summer Internship 360 Questions

Source: Internet
Author: User

   Programming One:   little B has recently been fascinated by string processing techniques, he has designed various processing methods, and computed the properties of strings. This is no exception, he defines a new method of character substitution. Small b Study of strings by ASCII code letters and "." , the object of this study is "." The object He cares about is the two consecutive "." Occurrences in a string. If each operation put the first two consecutive "." Instead, the function f (s) can be defined so that there are no consecutive two "." In the string. The minimum number of permutations.    now consider the M-character substitution operation, substituting the value of the Post function f (s) with the given character each time the character at the specified position is replaced.  

Programming Two: In order to test their mathematical ability, small b and small a often play a variety of numerical games together, this time they have a new play. Each person selects an integer from the specified range of values, and small a selects a value of a, and small B selects a value of B. They use a uniformly distributed random number generator to randomly generate an integer c in that range, defining the winning game rule for the number of people who choose to be close to C and who wins. Since small B is a girl, it is particularly defined when the difference between the number of two people and C is equal, the small B wins. As a result of the previous game, small A for the performance of the gentleman is always lose more win less, so he particularly eager to give small B more profound image, so ask you for help. You already know the number of small B selected values and the specified range of values, small a I hope you help him choose a value so that he wins the most probability. The input has several lines, each of which acts as a set of data, containing two positive integers n and b, respectively, representing the number of values required for the range and small B, where 1<=b<=n<=10^9

Basic Knowledge Questions:

The difference between "1" charAt () and indexof ()

CharAt (Index)--Returns the character at the specified position

<script type= "Text/javascript" >var str= "Hello world!" document.write (Str.charat (1)) </script> the output of the above code is: E

IndexOf ()--finds a character from a location, returning the index value where the character is located .

String.IndexOf (substring, startIndex);//
    • SUBSTRING--substring to find
    • StartIndex--optional parameter, starting from the startpos position of string to find substring, if no this parameter will be found from the beginning of the string

such as the following example:

var str = "www.dreamdu.com";d ocument.write (Str.indexof ("Dream")); Output 4
str = "www.dreamdu.com";d ocument.write (Str.indexof ("Dudream"));//output-1 (indicates non-existent)
str = "www.dreamdu.com";d ocument.write (Str.indexof ("D", 6));//Output 9 find starting at 6th position
str = "www.dreamdu.com";d ocument.write (Str.indexof ("D", 20));//Output-1
str = "www.dreamdu.com";d ocument.write (Str.indexof ("D",-1));//Output 4
str = "Dream Capital";d Ocument.write (Str.indexof ("Dream"));//Output 0

Extended extension:

Three differences: Slice (start position, end position)--not including end position substring (start position, end position)--not including end position substr (start position, end position)--including end position, Change the negative to 0slice ( -1)--------to the last one). Substring-------gives a negative number, it automatically turns it into substring (-1)-to 0SUBSTR (start position, end position)-including the end position, and the negative number to 0

What are the request statuses for "2" XMLHttpRequest?

HTTP Processing Status:
When a XMLHttpRequest is first created, the value of this property (readystate) starts at 0 until the full HTTP response is received, which increases to 4. Each of the 5 states has an associated informal name, and the following table lists the status, name, and meaning:
0 uninitialized initialization state. The XMLHttpRequest object has been created or has been reset by the Abort () method. ----//initialization
The 1 Open Open () method has been called, but the Send () method is not called. The request has not been sent yet. ---------------//Call answering
The 2 Sent Send () method has been called and the HTTP request has been sent to the WEB server. The response was not received. ------------//Request a speech
3 receiving all the response headers have been received. The response body begins to receive but is not completed. --------------------//Accept Incomplete
4 Loaded HTTP response has been fully received. ---------------------------------------------//Fully accepted

In addition, the meanings of each of these different states can be viewed in the following list:

1XX-Informational Tip 100-The initial request has been accepted and the customer should continue to send the remainder of the request. (HTTP 1.1 New) 101-The server translates the client's request to a different protocol.    (HTTP 1.1 New) 2xx-Successful 200-ok everything is OK, the answer document for Get and post requests is followed.    The 201-created server has created the document, and the location header gives its URL.    202-accepted has accepted the request, but the processing has not been completed.    The 203-non-authoritative information document has returned normally, but some of the answer headers may be incorrect because a copy of the document is being used, non-authoritative (HTTP 1.1 new). 204-no Content does not have a new document, the browser should continue to display the original document.    This status code is useful if the user refreshes the page on a regular basis and the servlet can determine that the user's document is new enough. 205-reset content is not new, but the browser should reset what it displays.    Used to force the browser to clear the form input (HTTP 1.1 new). The 206-partial Content client sends a GET request with a range header that the server has completed (HTTP 1.1 new).
3XX-Redirected 300-multiple Choices The documents requested by the customer can be found in multiple locations that have been listed in the returned document. If the server wants to make a preference, it should be indicated in the location answer header. 301-moved permanently The document requested by the customer elsewhere, the new URL is given in the location header, and the browser should automatically access the new URL. 302-found is similar to 301, but the new URL should be treated as a temporary replacement, not a permanent. Note that the corresponding status information in HTTP1.0 is "Moved temporatily". When the status code appears, the browser can automatically access the new URL, so it is a useful status code. Note that this status code can sometimes be used with 301 substitutions. For example, if the browser mistakenly requests Http://host/~user (the trailing slash is missing), some servers return 301, and some return 302. Strictly speaking, we can only assume that the browser will automatically redirect only if the original request is get. See 307. 303-see other is similar to 301/302, except that if the original request is post,location, the redirect target document specified by the header should be fetched via get (HTTP 1.1 new). The 304-not Modified client has a buffered document and issues a conditional request (typically providing a if-modified-since header indicating that the customer only wants to update the document than the specified date). The server tells the customer that the original buffered document can continue to be used. 305-use Proxy The document requested by the client should be extracted via the proxy server indicated by the location header (HTTP 1.1 is new). 307-temporary Redirect and 302 (Found) are the same. Many browsers incorrectly respond to a 302 response for redirection, even if the original request is post, even though it can actually be redirected only if the answer to the POST request is 303. For this reason, HTTP 1.1 has been added in 307 to allow for more cleanup of the region in several status codes: When a 303 response occurs, the browser can follow the redirected get and post requests, and if the 307 answer, the browser can only follow the redirect to the GET request. (HTTP 1.1 New) 4xx-Client Error 400-bad request syntax error occurred. 401-unauthorized access was denied and the customer attempted to access a password-protected page without authorization.A www-authenticate header is included in the answer, and the browser displays the user name/Password dialog box, and then makes a request again after filling in the appropriate authorization header. 404-not Found could not find the resource at the specified location. This is also a common answer. The 405-method not allowed request method (GET, POST, HEAD, DELETE, PUT, trace, etc.) does not apply to the specified resource, and the HTTP verb used to access this page is not allowed (the method is not allowed) (HTTP 1.1 new) 406-n OT acceptable the specified resource has been found, but its MIME type is incompatible with the client specified in the Accpet header, the client browser does not accept the MIME type of the requested page (HTTP 1.1 new). 407-proxy authentication Required requires proxy authentication, similar to 401, to indicate that the client must be authorized by the proxy server first. (HTTP 1.1 new) 408-request Timeout the customer has not made any requests during the server license wait time. Customers can repeat the same request at a later time. (HTTP 1.1 new) 409-conflict is usually associated with a put request. The request cannot succeed because the request conflicts with the current state of the resource. (HTTP 1.1 new) 410-gone The requested document is no longer available, and the server does not know which address to redirect to. It differs from 404 in that returning 407 means that the document has permanently left the specified location, and 404 indicates that the document is unavailable for unknown reasons. (HTTP 1.1 new) 411-length Required The server cannot process the request unless the client sends a content-length header. (HTTP 1.1 new) 412-precondition Failed Some of the prerequisites specified in the request header failed (HTTP 1.1 new). 413–request Entity Too Large the size of the target document exceeds the size that the server is currently willing to handle. If the server thinks it can process the request later, it should provide a Retry-after header (HTTP 1.1 new). 414-request URI Too Long URI is too lengthy (HTTP 1.1 new). 415– media types not supported. 416–requested RangeThe not satisfiable server does not meet the range header specified by the customer in the request. (HTTP 1.1 New) 417– execution failed. 423– a locked error. 5xx-Server Errors 500-internal Server error servers encountered unexpected conditions and could not complete customer requests. The 501-not implemented server does not support the functionality required to implement the request, and the header value specifies the configuration that is not implemented. When a gateway or proxy is 502-bad, the server returns an illegal response in order to complete the request to access the next server. It also says that the Web server received an invalid response when it was used as a gateway or proxy server. The 503-service unavailable service is unavailable and the server is unable to answer due to maintenance or overloading. For example, a servlet might return 503 if the database connection pool is full. A retry-after header can be supplied when the server returns 503. This error code is specific to IIS 6.0. When the 504-gateway Timeout network is timeout, it is used by the server acting as the proxy or gateway, indicating that the answer cannot be received from the remote server in a timely manner. (HTTP 1.1 new). The HTTP version indicated in the request is not supported by the 505-HTTP version not supported server. (HTTP 1.1 new).

"3" How to get any number in a range?

function Getrandom (Min,max) {return Math.floor (min+math.random ()* (max-min));  Math. Random () is a pseudo-random double value that is randomly selected for a system that is greater than or equal to 0.0 and less than 1.0}
var random=getrandom (2,8)//Get arbitrary random number between 2-8

< turn >2016 Summer Internship 360 Questions

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.