This Was a Jane Street interview question - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › This Was a Jane Street interview question (1216 Views)
| This Was a Jane Street interview question by turmacs(op): 4:21pm On Jun 19, 2024*. Modified: 6:31pm On Jun 19, 2024 |
If you hate/don't know math, kindly close this thread now ![]() For those of you that hope to work at Hedge fund companies, Jane Street, Citadel or other trading firms, expect stuff's like these at your interviews ![]() If you can't solve it and would like to know how to solve it, kindly quote me so I'd know that somebody is interested in the solution and I would drop the solution with explanations here. Problem statement Let us call the Euclidean mean of a permutation P the value of the expression |P1 - 1| + |P2 - 2| +....+ |Pn - n|. As an example, for the permutation [1,2,3], the Euclidean mean is |1 - 1| + |2 - 2| + |3 - 3| = 0, and for the permutation [3,1,2], the Euclidean mean is |3 - 1| + |1 - 2| + |2 - 3| = 2 + 1 + 1 = 4. Given two whole numbers n and k, as inputs, Find a permutation P of length n such that it's Euclidean mean is equal to k, or report that no such permutation exists. A permutation of length n is an array of n distinct integers that contains integers from 1 to n in random order. For example [2,4,1,3] is a permutation of length 4, but [3,3,1] is not a permutation because 3 appears twice in the array, and [1,3,7] is also not a permutation because n = 3 but there is 7 in the array. Also note that |x - y| represents the absolute value of x - y. Input The first line consists of an integer t (1 ≤ t ≤ 104) ---- The number of test cases. The only line of each test case consists of two integers n and k (1 ≤ n ≤ 2⋅105, 0 ≤ k ≤ 1012), the length of the permutation and the required Euclidean mean. Output For each test case if no such permutation exits, output "No". Otherwise, in the first line, output "Yes", and in the second line, output n distinct integers P1,P2,…,Pn (1 ≤ pi ≤ n) ----- A suitable permutation.. If there are multiple solutions, you can output any of them. Example Input 8 3 4 4 5 7 0 5 16 8 14 112 777 5 12 5 2 Output Yes 3 1 2 No Yes 1 2 3 4 5 6 7 No Yes 8 2 3 4 5 6 1 7 No Yes 5 4 3 1 2 Yes 2 1 3 4 5 |
| Re: This Was a Jane Street interview question by xokol8: 5:10am On Jun 24, 2024 |
The answer? turmacs: |
| Re: This Was a Jane Street interview question by turmacs(op): 7:05am On Jun 28, 2024 |
xokol8:Solution coming soon ![]() |
| Re: This Was a Jane Street interview question by turmacs(op): 8:24am On Jun 28, 2024*. Modified: 3:29pm On Jul 08, 2024 |
![]() |
| Re: This Was a Jane Street interview question by turmacs(op): 8:44am On Jun 28, 2024 |
You can also use chatgpt to convert the solution to any programming language you want so that you can understand it ![]() |
| Re: This Was a Jane Street interview question by MindHacker9009(m): 2:14pm On Jul 21, 2024*. Modified: 9:29pm On Jul 28, 2024 |
That's not Software Development but A/Level maths. Software Development is when you take your maths problem and make it available through a secure API for display on users web browsers with authentication and authorisation and also save and retrieve the data securely from a database or datastore with optimisation. |
| Re: This Was a Jane Street interview question by Emeka71(m): 5:53pm On Aug 20, 2024 |
turmacs:Interesting coding. |
| Re: This Was a Jane Street interview question by danielclerkson: 4:13am On Aug 21, 2024 |
MindHacker9009:You are so far off. Check online for DSAs, i hate to agree with turmacs but this is inevitable if you want to go far in Software Developement |
| Re: This Was a Jane Street interview question by MindHacker9009(m): 1:18pm On Aug 21, 2024*. Modified: 3:06pm On Aug 25, 2024 |
danielclerkson:DSA can be applied to all software development projects and it's not only for mathematician's problems, so you are the one so far off. Most complex programming projects you'll find in the real world will be something like this one below and not A/Level maths or Bsc Maths problems. Programming only require good logical thinking and not A/Level Maths or Bsc Maths. Implement a piece of online software suitable for use by a cinema. The system should be capable of providing information about films currently showing, and of the availability of seats in the cinema. The system should allow for seats to be booked either individually or as a block. For example a block of 5 seats would require 4 adjacent seats to be booked together.
|
| Re: This Was a Jane Street interview question by danielclerkson: 10:17pm On Aug 21, 2024 |
MindHacker9009:Whats up with you and this problem, you just keep bringing it on (hope i am not talking to some kinda bot) |
| Re: This Was a Jane Street interview question by MindHacker9009(m): 10:46pm On Aug 21, 2024*. Modified: 11:13pm On Aug 21, 2024 |
danielclerkson:I should be asking you instead. All these Maths bots on Nairaland that has no where else to use that Maths they have been cramming, but have decided to come and be disturbing us real programmers here. If you believe you are a good Mathematician go and invent the next super operating system better than Windows or Linux and leave us real programmers and Software Engineers alone to face real life programming projects. |
| Re: This Was a Jane Street interview question by danielclerkson: 11:07pm On Aug 21, 2024 |
MindHacker9009:I admit i may not be Alan turing, but atleast i know well enough to proofread and spell check everything before i post |
| Re: This Was a Jane Street interview question by MindHacker9009(m): 11:15pm On Aug 21, 2024 |
danielclerkson:Okay you are now the spell checker bot on Nairaland. |
| Re: This Was a Jane Street interview question by danielclerkson: 3:45am On Aug 24, 2024 |
MindHacker9009:Sorry Sir, if you are so knowledgeable I don't think you would have made such a mistake oh |
| Re: This Was a Jane Street interview question by MindHacker9009(m): 9:59am On Aug 24, 2024*. Modified: 1:21pm On Aug 24, 2024 |
danielclerkson:Spelling 'believe' as 'beleive' is a minor mix-up, which is a very common mistake that many people make. And you, Mr. knowledgeable bot, cannot even write correct grammar and spellings in your posts below: danielclerkson:Spelling bug as but and using SQL inject instead of SQL injection danielclerkson: |
| Re: This Was a Jane Street interview question by MindHacker9009(m): 8:23pm On Aug 27, 2024*. Modified: 8:42pm On Aug 27, 2024 |
ChatGPT solution in less than a minute with C# console app:
|
Solve This Amazon Interview Question • 2 • 3 • 4
Where Can I Do Computer Networking Programme In Portharcourt? • Vb Concepts • C-Sharp Programming Mentor Needed


;