gridland | Gridland - A Weird Little Time Waster by doublespeak games
kandi X-RAY | gridland Summary
kandi X-RAY | gridland Summary
Gridland
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of gridland
gridland Key Features
gridland Examples and Code Snippets
Community Discussions
Trending Discussions on gridland
QUESTION
I was solving this question on hackerRank. I have gone through the whole discussions section, tried all the suggested test cases with expected results. I think I might be doing some silly code mistake as I'm sure I've thought/considered every scenario in the implementation. could you please help me out pointing if there is any mistake in my code.
...ANSWER
Answered 2020-May-08 at 17:01If your code reads r,c1,c2
followed by r,c1,c2'
with c2'
, it'll silently drop the former track.
QUESTION
I'm facing a weird overflow issue with a Hackerrank Problem. Here's the brief of the problem statement.
There is a 2D array, and in each row of the array there are lines starting at one cell and ending at another cell (left to right in the same row). Now there can be multiple lines in one row and they can certainly overlap one another. The task is to find the number of unoccupied cells in the 2D array.
It is important to note that the dimensions of the array can be really big upto 10^9
. So this was my approach
- Use a map that would have the row number as the key and a vector of pairs as its corresponding value. The pairs are nothing but the start and end index of a line in that row.
row -> vector>
- Sort each such vector by the first element of the pair (i.e the start index of the interval).
- Merge the overlapping intervals for all the rows. For each merged interval calculate its length
wR - wL + 1
wherewL
andwR
are the start and end indexes of the interval respectively. Add the length of all these intervals and store in a variablesum
- Lastly, subtract that
sum
fromn*m
to get the number of unoccupied cells.
Here is the relevant code
...ANSWER
Answered 2020-Apr-28 at 16:49Answering my own question as I just found out the issue. The problem was with the pre-written code or template that was provided. It was expecting an integer while my code was returning a larger value. So changing,
int result = gridlandMetro(n, m, k, track);
to
ulld result = gridlandMetro(n, m, k, track);
fixed it.
I did not expect that the boilerplate code would be faulty.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gridland
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page