You are not logged in. Please login at to post your questions!


Getting TLE in Hackerearth The Parking Slot problem

I am gettign TLE for The Parking Slot problem on hackerearth, here is the link to my code, I have used dijkstra's algorithm.

Help needed in getting AC for this problem.

asked 26 Jun, 09:37

arpit728's gravatar image

accept rate: 10%

There was problem in your dijkstra code. You were always pushing into the queue. But you should do that only when needed. Just change this and you get AC.

     if(d[edge.v][DISTANCE]>d[u.v][DISTANCE] + edge.w){
                    d[edge.v][DISTANCE] = Long.min(d[edge.v][DISTANCE], d[u.v][DISTANCE] + edge.w);
                    queue.add(new Edge(edge.v, d[edge.v][DISTANCE]));


answered 26 Jun, 11:24

soham1234's gravatar image

accept rate: 22%

edited 26 Jun, 11:25

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 26 Jun, 09:37

question was seen: 93 times

last updated: 26 Jun, 11:25