Search results
Aug 3, 2016 · 3. This is my solution to the Equal Stacks problem on HackerRank. I thinks it's really messy and slow. could you give me some thoughts about how to optimize given code and algorithm (i'm pretty sure problem can be solved way effectively) import java.io.*; import java.util.*; import java.util.stream.*; import java.text.*;
Dec 12, 2018 · Hackerrank "Almost Equal" solution. Ask Question Asked 5 years, 10 months ago. Modified 5 years, 2 months ago.
Jun 22, 2017 · Here is the original problem, and below is my solution (passing). It's asking to implement a queue with 2 stacks, which means I cannot simply use Array.shift. I wonder if the solution can be improved. Is there a better way than this to implement a queue with 2 stacks?
Jun 20, 2017 · Stack Exchange Network. Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Dec 6, 2017 · I hope this kind of optimization stuff will come to me as I practice more hackerrank problems. I'm confused about the nested while loop loop. I see that is calculates the max value and that the while loop eventually counts to 0 for the false condition, but I don't know what the max var is doing and how it is utilized against stack[i]. \$\endgroup\$
Nov 21, 2016 · Stack Exchange Network. Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Sep 30, 2018 · L[i] L [i] is the amount of luck associated with a contest. If Lena wins the contest, her luck balance will decrease by L[i] L [i]; if she loses it, her luck balance will increase by L[i] L [i]. T[i] T [i] denotes the contest's importance rating. It's equal to 1 1 if the contest is important, and it's equal to 0 0 if it's unimportant.
Aug 3, 2019 · 4. put `4` in `s1`. 5. move `3` from `s2` to `s1`. 6. move `2` from `s2` to `s1`. 7. move `1` from `s2` to `s1`. We see that the n n th element will take 2(n − 1) 2 (n − 1) swaps. Therefore, if we insert a total of n n elements into our queue, we end up with O(n2) O (n 2) to complete all enqueues.
Sep 18, 2014 · I put your version into hackerrank and the result is this. It still is about 5 times slower than my solution but it passes all tests, and that is good, especially as your code is much easier to read. I will now work trough your solution and explanation to understand it fully. \$\endgroup\$ –
Jun 9, 2017 · abc. Sample Output. 4. Explanation. We delete the following characters from our two strings to turn them into anagrams of each other: Remove d and e from cde to get c. Remove a and b from abc to get c. We must delete characters to make both strings anagrams, so we print on a new line.