S O U N D W A V E
BAN USER- 3 Answers How to delete an account?
I've emailed careercup support 5+ times already (no response) about having this account deleted. Does anyone work actively on this site at all?
- S O U N D W A V E November 27, 2013
I occasionally get emails for recent comments to questions even though I'm not subscribed to this.
The unsubscribe link in this email leads to nothing useful (as I'm not subscribed to this service to begin with).
How do I contact the people who run careercup? How to stop the sporadic spam emails?
I just got this email (which is considered spam now) :
undefined has commented on a question.
You are given an array in which you’ve to find a subarray such that the sum of elements in it is equal to zero.
He algo is nice.
However, In java it is not easy using the hashMap to get the key of values if we use hashmap(index,value). And if we want to use hashtable(value,index), the array cannot have dup as it will have the same key and cover the previous value. We can use a biMap to handle it.
if we don't want to use biMap here is my solution using two hashMap.
static void sumEqZero()
{snip}
View » | To unsubscribe, login and click here.| Flag | PURGE
lol cool
we were on our way to proving that paper (for euclidean distances) right in this careercup thread
including the part where if notanexpert's conjecture were true (which he was onto proving), we could use square on distances and eliminate infinite solutions that arise from using distance directly
then we could work with the simplified objective function which has abs^2 which makes the functions nonsingular after differentiation
nothing too drastic in that paper
+1000 to @justin @notanexpert @den @nothing_special
And I don't see any examples from him.
Just function signature, and constraints (not "objective" just constraints).
And some code with some comments that don't match the previous signature and constraints.
:) Your code is great and upvoted, but I have a problem with the question (and questioner).
It is not at clear what is to be returned.
It is not at clear what happens if N=2 and K=[6, 4.5, 2]
Or N=3, K=[1,2,3]
Or what "k is less than N" in the comments of his code mean.
Based on his question we can even get negative probabilities.
+1
It's a weekly homework question, and he/she is giving it a last go.
We would need more than the conjecture to be not true (because his conj. is for 2 points). If a solution has no points on it, then we can wiggle to get infinite solutions.
Suppose "one" solution has k points on one side and k points on the other side of the line, wiggling the line a little in direction of its perpendicular. This will take away k*(wiggle) from one side of points and add k*(wiggle) and the new line should have the same total perp. distance.
@den nice. I just returned from 10+ min. of frustrations on this pain in the neck point too (which comes pretty early on in proof).
This can only mean we have to resort to abs(x) = sqrt(x^2) to make it differentiable "in some sense", but then you get a singularities to deal with later in the proof (because derivative will be |x|/x * dx/dvariable, which is not even defined at x=0) . It can be done but then we have to handle all these singularity points as possible critical points....
.... another point, pun intended...
The question seems funky. His/her professor probably meant "minimize square on the perpendicular distances." Because think about it (including @notanexpert's conjecture), if the conjecture is not true, then we can get away with "translating" the solution line in the direction of the perpendiculars (which will all be in same direction for any solution :P) and get equally minimum solutions - infinitely many of them. So it all seems fishy....
This does suggest that IF this question is a well posed problem, that notanexpert's conjecture would need to be true to force unique solutions.
Else, I think we should be minimizing squares on perp. distance to prevent this "sliding to create infinite solution lines." This would also make the math way easier.
What do you think @den?
I'm curious to see a more detailed version of proof of notatexpert's conjecture also.
Let { (x1,y1), ... , x_n, y_n) } be your points (don't fill numbers in).
Now assume general form of the solution line ax + by = c, where a,b,c are parameters.
Derive formula for perp. distance between the above line and anygeneral point (x_i,y_i).
Now create an overall objective function
Obj(a,b,c) = SUM{from i=1, to n} ( perp_dist( (x_i, y_i) , ax+by=c ) )
Now find dO/da, dO/db, dO/dc , set them to zero.
We should be able to get a,b,c as functions of x_i, y_i with a bunch of sigma notation going from i=1 to n.
The formula should be O(n) , that is with sigma notations going from i=1 to n with constant work inside each sigma, and be totally independent of what the actual points are (we do proof above with general variables x_i, y_i).
Now we hard code the formula in our function and use it.
We do a linear pass on the array of points and accumulate whatever each "sigma" needs in the end.
{Missing is proof that the critical point we get above by setting the three partials to 0 is actual a min., and not a saddle or max., but we work on faith here}
Now @notanexpert, from the result of finding the formulae for a,b,c we should be able to "see" by inspection if your conjecture is true or has possible counterexamples.
I wonder too.
What he said reminds me of Sylvester Gallai theorem, which isn't relevant here.
it would be a 3 variable optimization problem because the question is pain in the neckingly defining a line in the most general form ax + by + c
so you will get partials with derivatives w.r.t to a, b, c , set them to 0 and mash on paper for 30+ min.
Answer please? I will have someone look into this.
Assuming 2D plane of doubles (approximating real numbers), you can derive a formula on paper ( 2 variable minimization problem , find partials set them to zero and solve).
Curious who asked who asked you this.
It uses an O(n) stack secretly.
And on this stack there are n pointer objects.
The question is dumb.
Which location and what job title was the interview? Curious.
- S O U N D W A V E November 02, 2013that uses 2 pointers, doesn't matter how you try to sugar coat it
the question is dumb but u _might_ be able to get an idea from "xor linked lists" (google it)
these folks were talking on chat and it boiled down to heavy restrictions
well it boiled down to "don't waste ur time on them because they are too dumb to even state the problem clearly enough to help them"
N==K.length*
- S O U N D W A V E November 02, 2013No idea.
The way question is stated you can even make the computer cry by calling function with K[ ] which has length == K.length
even we assume the numbers in K[ ] are a subset of {1,...,N}
and then use uniform prob 1/(N-k) we should be fine.
But the questions has weird cases. Division by zero. K.length > N. And I don't even know what prob 1/(N-K.length) means in most cases.
TBH I don't really understand the question. To me it's underspecified.
I thought it meant probability is
1 / ( N - k ) where k is the number of elements of K[ ] in the range 1 ... N
But it says k=K.length.
0 would pass the 99 test *
- S O U N D W A V E November 01, 2013you might try binary search to identify if the randint(1,N) you flipped was in K[ ], and if it is... you...
- S O U N D W A V E November 01, 20130, 1, 2, 3, 4, 5, 6, 7 are counter examples
I would be angry at someone if he/she asked such a question as if it was a pure coding exercise then expected some neat O(1) formula for generating the kth such number.
should be a2+=(number in front of x^2), a1 += ( in front of x)
and -= on right side
some absolute idiot, not saying it is you, kept begging people to help him to code this from around a week ago (on chat)
expand both sides out, collect like terms (3 counters a2++, a1++, a0++ on left side, and -- when seen on right side... for coefficients of a2*x^2 + a1*x + a0).
After all that is said and done, check if a2 is 0, if so easy...
If a2 is not zero, check discriminant and build 3 cases on that
highschool homework I think (please no alg, they asked for coded solution)
this place is garbage lately
Question doesn't say what the input to the function, so let's throw out ideas ourselves.
My first idea is to have outter function take a certain "width" of octal numbers...
1) Then we create all octal numbers that are of that width from the endpoints (we can backtrack to create all such palindromic octal numbers).
2) We pack the octal 3 bits together to create binary representation (you can do it as part of 1)
3) Convert to BCD (can optimize above to make this part fast as part of shift and add algorithms or whatnot). Then we scan the BCD numbers from the ends to see if they are palindromic too.
Might try coding it in evening.
library functions is something above brute force
still any idiots can solve most of the recent questions posted on here
lowest? highest?
Why did you use those terms instead of last and first? :)
Job title? Google Research, some sort of machine learning team?
- S O U N D W A V E November 01, 2013Processors can do a lot with groups of bits at the same time. For example, 4 or 8 bytes of bits can be in O(1) used to do indirect addressing.
And other bit operations can do byte or integer wide bit operations in the common machine cycle on most CPUs.
The two ideas above can lead to two different possible solutions (LUT for first, popcount type thing second. The second method is someone else's specialty, and I suspect he will remember this thread and post his solution eventually.)
Correct. A lot of solutions boil down and optimize to yours above (especially the highest upvoted one).
But you can optimize yours too. No need for log.
+ 10^6
- S O U N D W A V E November 01, 2013This one isn't needed. In worst case it is as bad in #humans required as the cei(log_2 (n)) "need results immediately" problem, yet it doesn't guarantee results within poison time period.
- S O U N D W A V E November 01, 2013nice
- S O U N D W A V E November 01, 20138 directions , counting all paths
int count;
bool seengrey; //externals for convenience
void _countpaths(A, i, j)
{
if( i<0 || j<0 || i==A.length || j==A.length) return; //out of bounds
if( i==A.length-1 && j==A.length-1 && seengrey) count++, return; //end of proper path
if( A[i][j] == 1 ) return; //black
if( A[i][j] == 2 ) {
if( seengrey ) return; //grey but already seen grey
else seengrey = true; //just discovered grey
}
else A[i][j]=1; //white so mark it black
for(int u=-1; u<2; u++)
for(int v=1; v<2; v++)
if( !(u==0 && v==0) ) countpaths(A, i+u, j+v);
if( A[i][j] == 1) A[i][j]=0; //if black, was original white
else seengrey=false; //else it was grey, so unmark seeing grey
}
int countpaths(A)
{
count=0, _countpaths(A,0,0), return count;
}
Ignore this post above.
- S O U N D W A V E October 26, 2013So pseudopolynomial time alg?
- S O U N D W A V E October 26, 20138 direction , counting all paths
int count;
bool seengrey;
void _countpaths(A, i, j)
{
if( i<0 || j<0 || i==A.length || j==A.length) return; //out of bounds
if( i==A.length-1 && j==A.length-1 && seengrey) count++, return; //ends proper path
if( A[i][j] == 1 ) return; //black
if( A[i][j] == 2 ) {
if( seengrey ) return; //grey but already seen grey
else seengrey = true; //just discovered grey
}
else A[i][j]=1; //white so mark it black
for(int u=-1; u<2; u++)
for(int v=1; v<2; v++)
if( !(u==0 && v==0) ) countpaths(A, i+u, j+v);
if( A[i][j] == 1) A[i][j]=0; //if black, was original white
else seengrey=false; //else it was grey, so unmark seeing grey
return;
}
int countpaths(A)
{
count=0;
return _countpaths(A,0,0);
}
Typed it raw.
- S O U N D W A V E October 26, 2013@julius
How do you know?
Another ambiguous question. 1 min. to type by OP, then hours wasted by everyone else.
Inefficient.
@Siva,
Can you create a min-heap using pointer linked structures?
That's NP-complete.
- S O U N D W A V E October 26, 2013Forgot the +1:
int check (Node x)
{
if (x==nil) return 0;
if( (N=check(x.left) ) == check(x.right) ) return N+1;
return -1;
}
Recursive:
int check (Node x)
{
if (x==nil) return 0;
if( (N=check(x.left) ) == check(x.right) ) return N;
return -1;
}
Note: returns -1 on false, >=0 on true (num levels)
- S O U N D W A V E October 26, 2013hmmm ok... homework?
for(int i=0; i+2<a.length; i+=3) swap(a[i], a[i+2]);
Above one liner looks familiar :) This question was asked a few weeks ago.
Except LMax need not be an array (you can update it on the fly).
All you really need is ~1n storage and ~2n passes.
Above looks familiar. You posted code almost identical to this in another thread after I solved the this same question in there.
Cool. Anonymous isn't really anonymous ;)
Too many idiots posting questions. I don't care if I offend anyone.
Nowhere does the question define n.
AND even if n is defined, we need to know if it's
1) Fixed throughout the whole junk
2) Fixed within each word
3) Indepedent for each character
All are easy modifications from the same base code.
The quesiton is meaningless.
What does "this is valid because n is blah blah"
This is invalid because n is not blah blah mean.
The inequalities are irrelevant if n is not defined lol
hugakakka (spelling) the original poster can "define n" first before using it to define a whole bunch of other things next time he/she posts a question.
Whatever version you want, the code should still be a few-liner.
Come on chat and debate this question with me :)
- S O U N D W A V E October 26, 2013@ Krz,
I agree, anything can be anything.
Definitions are labels.
We need to move away from definitions and relying on them to write 6 word questions thus leading to multi-paragraph debates.
But yeah, if some random dude asked "What is a blah blah for BST?" I'd assume he meant the most basic form.
Repmylakleinm, Quality Assurance Engineer at Coupon Dunia
Articulate and accomplished admin executive experience at keeping an office running smoothly. A communicator and collaborator who is efficient in ...
Repherminanmuller87, Animator at 247quickbookshelp
Hello,I am a literacy teacher. I completed my degree from Chicago and now am a literacy teacher in a ...
Repjanistbennett, Blockchain Developer at AMD
I am JanisBennett working as a journalist, having years of experience in my career. I have covered various stories.Great ...
Repgarlandkrebs, Animator at ADP
Highly focused and seasoned magazine editor with vast experience in all stages of weekly and monthly magazine production. My aim ...
Repannawellson007, Area Sales Manager at 8x8
Hey my name is anna And i am working as a content writer in Search engine optimization company.My component ...
Repneshujaha, Member Technical Staff at BMO Harris Bank
I am Neshu, a Camera Operator with a creative eye for detail and dedication to quality work. I am always ...
RepLooking for the best child development center in Charlotte? Pal A Roos provide summer camp for children Charlotte. Our experienced ...
RepRobertBaumbach, Administrative Manager at Meridian Mechanical Services
Reprafaeltanner210, Associate at 247quickbookshelp
I am Labor relations directors, oversee employment policies in union and nonunion settings. I draw up, negotiate, and administer labor ...
Repcolettehenna, OOPS Freshers at Bosch
I am Colette , policy analyst at Sunflower Market , with 3 years of experience building and maintaining relationships with elected officials ...
RepIndianastrologyguru, Data Scientist at ABC TECH SUPPORT
Hey I'm Shelly Renee and I'm working as a system developer. Currently working part time on a project ...
Repelisahbuff, Apple Phone Number available 24/7 for our Customers at Altera
I have previous work experience in a customer focused environment. I like to Enjoy my Free Time Playing football.I ...
Reptaylamowll, Analyst at AMD
Aspire to work in a challenging environment, where my exceptional skills and abilities are completely explored, and I can easily ...
Repamayalopez800, Accountant at A9
I am Amaya ,working in the field of training and development coordinator for three years, focusing on teaching English as ...
Reploragurrero, Research Scientist at Absolute Softech Ltd
I am Lora , an empathetic and dedicated Community Organizer with a deep passion for helping others and a strong determination ...
RepKellyLabbe, Animator at Future Advisor
My name is Kelly and I am currently a freshman Fitness trainer in Vibrant Man company .I have learned a ...
Repkarinkwalton, Backend Developer at Broadsoft
I am working as a Support clerk in an MVP Sports company. I love traveling and exploring facts about technology ...
RepTimothyAYocum1, Android Engineer at ABC TECH SUPPORT
I am a medical or osteopathic doctor who specializes in eye and vision care. My work Ophthalmologists differ from optometrists ...
RepGinaSanchez, Computer Scientist at Autoportal.com
Ginna from New York.Successfully managing a high volume of work assignments without compromising quality to exceed client expectations.Apart ...
RepDonnaArvin, Analyst at Apple
Hii am from the United States. I work as a computer control programmer at Dynatronics Accessories. I am a social ...
Reppamilarbowman, Animator at ABC TECH SUPPORT
Je travaille en tant que Web Manager dans la société Forum Cafeterias. Je veux tout savoir sur le marketing numérique ...
haha no i don't want to waste the 30 seconds to do this
- S O U N D W A V E November 03, 2013anyone who bothers answering this thread with code is just a little bit less of an idiot as you are