This article comes from NetEase cloud community.How can you quickly get a large number of target users at a low cost, rather than a protracted war with your competitors?This is not common on the internet today. Now, most of the industry is already a long time competition in the Red Sea, and the blue Ocean market technology, resource barriers are very high, the general product is far behind. In the fierce competition of the Red Sea market, how can we a
This article comes from NetEase cloud community.How can you quickly get a large number of target users at a low cost, rather than a protracted war with your competitors?This is not common on the internet today. Now, most of the industry is already a long time competition in the Red Sea, and the blue Ocean market technology, resource barriers are very high, the general product is far behind. In the fierce competition of the Red Sea market, how can we a
Yesterday for the first time to participate in a Hackerrank game, from 11 o'clock Noon to do the night 12 o'clock, finally too tired, at the end of the game one hour to go to bed. Completely passed the first two questions, the third question for a sentence has not been correctly understood, so did not pass the majority of test case, the final ranking in the contest in 23**/60**. Oneself is holding the mentality of study to go, although this achievemen
Research competitors
The internet is a great place for someone to make their fortune but to be secretive. It is now impossible that you will be able to reach the top of the search engine without first withholding your way through a group of competitors. Tips to make this journey easier for you to educate your competitors and take advantage of any opportunities y
The optimization of the site competition is growing, every day there are more and more Web sites generated, at any time to create threats to us, we also want to go beyond our stronger competitors every day, then how can we better surpass our competitors? I think this is the core factor of every webmaster friend's thinking, We need to think about how to better the Web site weight up, how to improve the keywo
website, to do than competitors also know his site? Think billion European believe is possible, probably share a few ideas:
First, focus on competitors ' ranking:
Search engine optimization of any strategy, the ultimate goal is to enhance the site in search engine performance, in search engine performance reflected in the site's ranking. If you can focus on the thousands of different rankings on a compet
How to analyze a competitor's site? How to Use competitors for Seo Optimization
As a website, no one can guarantee that the ranking of a website on a certain keyword is permanent, and no website ranking is positive.
Search EngineAlgorithmIt's changing. The website's strength is increasing, weakening, and competitors are increasing.
So how can we use the advantages of our
second by second. the problem is that the protein rings can be very long (up to 1 million proteins in a single ring) and they want to know the state of the ring after upto 109 seconds. thus their software takes too long to report the results. they ask you for your help.
Input FormatInput contains 2 lines.First line has 2 integers n and k, n being the length of the protein ring and K the desired number of seconds.Second line contains a string of length N containing uppercase letters A, B, C or
Question Link
Ashton appeared for a job interview and is asked the following question. arrange all the distinct substrings of a given string in lexicographical order and concatenate them. print the kth character of the concatenated string. it is assured that given value of K will be valid I. e. there will be a kth character. can you help Ashton out with this?
Input FormatFirst line will contain a number t I. e. Number of test cases.First line of each test case will contain a string containing
Similar Pair _ HackerRank, pairhackerrank
Hacker rank is really more difficult than leetcode ..
This question is a bit clever .. Each path is searched in depth and then enumerated. Most people think about it, but the key is that this definitely times out. The trick is to create a line segment tree for each path to accelerate the query. The complexity of each similar query changes from O (h) to O (lgh )..
Two mistakes were made.
(1) Use long to store
Greedy beats DP this time...
I tried several DP solutions first, but all failed with re \ TLE. If you 'feel' the problem, greedy shocould be working:
(A solution from discussion)
Def getiterator (n): While n> 0: If n % 3 = 0: break; else: N-= 5 return n t = input () for I in xrange (t): n = int (input () rows = getrows (n) If rows
Hackerrank-Sherlock and the beast
Another fun greedy problem to work on:we simply go from first to second last person, as long someone is odd, we distribut E bread to she and her next.#include #includeusing namespacestd;intMain () {intN; CIN>>N; Vectorint>B (N); for(intB_i =0; B_i ) {cin>>B[b_i]; } intCNT =0; for(inti =0; I 1; i + +) { if(B[i]%2) {B[i]++; B[i+1]++; CNT+=2; } } if(B.back ()%2) cout"NO"Endl; ElsecoutEndl; return 0;}Hackerrank "Fair rations"
An intuitive Prim algorithm impl.#include #include#include#include#includeusing namespacestd;structedge{Edge (): s (0), T (0), D (0{} Edge (unsigned RS, unsigned rt, unsigned rd): s (rs), T (RT), D (RD) {} unsigned s; unsigned t; unsigned D; BOOL operator()(ConstEdge e1,ConstEdge E2) { returne1.d >e2.d; }};intMain () {LongN, M; CIN >> N >>m; //From -to-and (length, id)unordered_mapG; for(inti =0; I ) {Unsigned A, B, D; CIN>> a >> b >>D; G[A][B]= G[b][a] =D; } unsigned s; CIN>>s; Un
"How many inverted pairs"-so usually ends up with mergesort solution (of course there is other solutions out there)defmergesort (arr):ifLen (arr) = = 1: return0, arr mid= Len (arr)//2Cnt1, arr1=mergesort (Arr[:mid]) Cnt2, arr2=mergesort (arr[mid:])#RET =[] CNT=0 I=0 J=0 Inx=0 whileI andJ Len (arr2):ifArr1[i] Arr2[j]: Ret.append (arr1[i]) I+ = 1elifARR2[J] Arr1[i]: Ret.append (arr2[j]) CNT+ = Len (arr1)-I#arr2-arr1J + = 1 whileI Len (arr1): Ret.append (Arr1[i]) I+ = 1 whileJ Len (arr2): R
I caught the sparkle in my mind and got AC1! It is a great great experience!So the basic Idea:permute on 3 consecutive items doesn ' t change the parity of the No. of inversions. Each permutation can is only remove 0 or 2 inversions. So we say "YES" when No. of inversion% 2 = = 0. And we use MergeSort to count it in O (NLGN).RET =0defmerge (arr1, arr2):Globalretif notARR1:returnarr2if notARR2:returnarr1 forV2inchArr2:arr1.append (v2) I= Len (arr1)-1 while(I >0):ifArr1[i] ]: Arr1[i-1],arr1[i] =
This is the classic LCS problem. Since it requires you-to-print one longest common subsequence, just use the O (m*n)-space version here.My accepted code is as follows.1#include 2#include 3#include 4 5 using namespacestd;6 7vectorint> LCS (vectorint> A, vectorint>b) {8 intn = a.size (), M =b.size ();9vectorint> > DP (n +1, vectorint> (M +1,0));Ten for(inti =1; I ) { One for(intj =1; J ) { A if(A[i-1] = = B[j-1]) Dp[i][j] = dp[i-1][j-1] +1; - ElseDP[I][J]
attended by up to a total.If m=1, of course, according to the end time sort, can.Here, simply deform, set b[j] for the point where the J-person is currently located (initially 0), for the first meeting, if there are more than one person to meet the criteria, select B[j] the largest one.Attached code:1#include 2#include 3#include 4#include 5#include 6 using namespacestd;7 8typedef pairint,int>PII;9 #defineF FirstTen #defineS Second One A intMain () { - intN, P; -scanf"%d%d", n, P); thePII t
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.