chicken.Zhang San: Start eating Kung Pao chickenJohn Doe: Start eating Kung Pao chickenZhang San: Kung Pao Chicken eaten upJohn Doe: Kung Pao Chicken eaten upWaiter: Two people please payWhat if you use AutoResetEvent for synchronization? What kind of results will happen? I'm afraid Zhang San and John Doe are going to fight, one to enjoy the delicious Kung Pao chicken, and the other to pay the bill while still playing games. Interested friends can remove the comment line code comment, and the f
Containerid/bin/bash to create a new shell UI
Use the Docker EXEC command to perform some of the commands in container, where/bin/bash represents the shell program for Linux
After entering the shell interface, we use the command mysql-uroot--p to enter the MySQL management interface, after entering the command, the system will prompt you to enter the MySQL root account password, enter the password we set when running this container
Enter show databases; command
Topicssubstring with the longest no repetition charactergiven a string, find the oldest string in which there are no repeating characters. For example, in which the "abcabcbb" oldest string with no repeating characters is "abc" , its length is 3 .For, the "bbbbb" oldest string with no repeating characters is "b" , length is 1 .SolvingUse Hashmap,map to always join, exist, find the same character position, situation map, change subscript Public classSolution {/** * @params:a String *@return:
Suppose a sorted array is rotated on some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.The array may contain duplicates.Given [4,4,5,6,7,0,1,2] return 0 Public classSolution {/** * @paramnum:a rotated sorted array *@return: The minimum number in the array*/ Public intFindmin (int[] num) { //Write your code here if(num = =NULL|| Num.length = = 0) return0; intleft = 0; intright = Num.length-1; while(Left
the required quotient, the equals sign should be approximately equal)Any integer can be represented in binary, so x=2^m + 2^n + ... + 2^t, where m > N > T,m,n,t are integers.X can also represent x = 1*2^m + 0 * 2^ (m-1) + 1 * 2^ (m-2) + ... + (1 or 0) *2^0.In fact, X can also say:x = (2^k + 2^ (k-1) + ... + 2^0) + (2^t + 2^ (t-1) +/... + 2^0) + ... + (2^r + 2^ (r-1) + ... + 2^0), where K > t is not a Gt ... > R.So a = b * (2^k + 2^ (k-1) + ... + 2^0) +b * (2^t + 2^ (t-1) + ... + 2^0) + ... + b
Divide integersDivide-integers without using multiplication, division and mod operator.If It is overflow, return2147483647ExampleGiven dividend = 100 and divisor = 9 , return 11 . Public classSolution {/** * @paramDividend The dividend *@paramdivisor the divisor *@returnThe result*/ Public intDivideintDividend,intdivisor) { //Write Your code here intmax=Integer.max_value; intSign=1; if(divisor==0)returnMax; if(dividend==0)return0; if(divisorSign ; if(dividendSign ; LongTmp1
ENCR_AES_CBC auth_hmac_sha1_96sai1/proposal-2 encr_3des auth_hmac_sha1_ 96sar2/proposal-1 encr_3des auth_hmac_sha1_96Finally, both sides agreed to use 3DES and hmac_sha1_96 as encryption and integrity algorithms. Since both identities have been confirmed, the protection of subsequent messages requires only the two. If you are more careful, you will ask where the key comes from? Without the key, the IPSec SA is incomplete. The answer is that the key comes from Sk_d, which is discussed l
Given a string which contains only letters. Sort it by lower case first and upper case second.NoticeIt ' s not necessary to keep the original order of lower-case letters and upper case letters.Example"abAcD"for, a reasonable answer is"acbAD"ChallengeDo it in One-pass and In-place. Public classSolution {/** *@paramchars:the Letter Array Your should sort by case *@return: void*/ Public voidSortletters (Char[] chars) { //Write your code here if(Chars = =NULL|| Chars.
stringLongestpalindromicstring (stringstr)3 {4size_t n =str.size ();5 if(n = =0|| n = =1) 6 returnstr;7 8size_t start =0;9size_t Nmaxlen =0;Ten One for(size_t i =0; I i) { Asize_t J = i, k = i;//spread from center to side, respectively . - while(K 1 Str[k] = = str[k+1]) -k++;//case with the same letter: "AAA" the while(J >0 K 1 str[j-1] = = str[k+1]){ -k++;//Different letter cases: "ABA" -j--; - } + if(k-j+1>Nmaxlen) { -Nmaxlen = k-j+1; +Start
Given an array with N objects colored red, white or blue, sort them so, objects of The same color is adjacent, with the colors in the order red, white and blue.Here, we'll use the integers 0 , 1 with and to 2 represent the color red, white, and blue respectively.NoticeYou is not a suppose to use the library's sort function for this problem.You should does it in-place (sort numbers in the original array).ExampleGiven [1, 0, 1, 2] , sort it in-place to [0, 1, 1, 2] .ChallengeA rather straight for
Sort a linked list in O(n log n) time using constant space complexity.ExampleGiven 1-3->2->null, sort it to 1->2->3->null./*** Definition for ListNode. * public class ListNode {* int val; * ListNode Next; * ListNode (int val) {* This.val = val; * This.next = null; * } * } */ Public classSolution {/** * @paramhead:the head of linked list. * @return: You should return the head of the sorted linked list, using constant space complexity. */ PublicListNode sortlist (ListNode head) {//Wri
Given an absolute path for a file (Unix-style), simplify it.Example"/home/", ="/home""/a/./b/../../c/", ="/c"Challenge
Did you consider the case where path = "/../" ?In this case, you should return "/" .
Another corner case is the path might contain multiple slashes ‘/‘ together, such as "/home//foo/" .Should ignore redundant slashes and return "/home/foo" .
Public classSolution {/** * @parampath The original path *@returnThe simplified path*/ Publicstring Simplifypath
directly use-1% 3 and you'll get 2 automatically.
ExampleGiven [null, 21->9->null, 14->null, null] ,Return[null, 9->null, null, null, null, 21->null, 14->null, null]/*** Definition for ListNode * public class ListNode {* int val; * ListNode Next; * ListNode (int x) {* val = x; * next = NULL; * } * } */ Public classSolution {/** * @paramhashtable:a List of the first node of linked list *@return: A List of the first node of linked list which has twice size*/ Publiclistnode[]
Given a sorted linked list, delete all nodes that has duplicate numbers, leaving only distinct numbers from the Original list.ExampleGiven 1->2->3->3->4->4->5 , return 1->2->5 .Given 1->1->1->2->3 , return 2->3 ./*** Definition for ListNode * public class ListNode {* int val; * ListNode Next; * ListNode (int x) {* val = x; * next = NULL; * } * } */ Public classSolution {/** * @paramListNode Head is the head of the linked list *@return: ListNode head of the linked list*/ Public Static
Implement POW (x, N).NoticeYou don ' t need the precision of your answer, it's acceptable if the expected answer and your answer ' s Diffe Rence is smaller than 1e-3 .ExamplePow(2.1, 3) = 9.261Pow(0, 1) = 0Pow(1, 0) = 1ChallengeO (LOGN) time Public classSolution {/** * @paramx the base number *@paramn the Power number *@returnThe result*/ Public DoubleMypow (DoubleXintN) {//Write Your code here if(n = = 0) return1; if(n = = 1) returnx; if(N > 1){
Merge k sorted linked lists and return it as one sorted list.Analyze and describe its complexity.ExampleGiven lists:[ 2->4->null, null, -1->null],Return -1->2->4->null ./*** Definition for ListNode. * public class ListNode {* int val; * ListNode Next; * ListNode (int val) {* This.val = val; * This.next = null; * } * } */ Public classSolution {/** * @paramlists:a List of ListNode *@return: The head of one sorted list. */ PublicListNode mergeklists (listlists) { //Write yo
section (slack or Greedy method), and the sparse matrix is row-by-row computed.Step 3:dictionary Update. The dictionary is based on the column vectors, and the dictionary is naturally updated with Column-by-column. For example, now update a column, the corresponding red dot below, according to the red dot to find the corresponding signal (image), and then remove other unrelated images, get the following:
The Atom in the dictionary contributes to four images, and the purpose of our tuning
new file, but the read or write affects only the I node of the file, not the parent directory.Five, Utime functionThe access and modification times of a file can be changed with the Utime function.#include int utime(const char *pathname, const struct utimbuf *times);返回值:成功0,失败-1.The structure used by this function is:struct utimbuf { time_t actime; /* access time */ time_t modtime; /* modification time */}Two times in a struct are UNIX timestamps.The operation of this function and the priorit
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.