TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Haskell Skyline

52 pointsby pykelloover 9 years ago

5 comments

Chris_Newtonover 9 years ago
Perhaps I’ve misunderstood the problem, but the second solution shown here doesn’t seem to be correct: it always adds a trailing 0-height entry to the skyline, yet there could be an existing building touching or overlapping the newly added building, whose height is then lost.<p>For example, the code given appears to make<p><pre><code> skyline [(1, 2, 3), (2, 1, 4)] </code></pre> evaluate to<p><pre><code> [(1,2),(3,0),(4,0)] </code></pre> when if I’ve understood correctly it should be<p><pre><code> [(1,2),(3,1),(4,0)]</code></pre>
评论 #10724876 未加载
jzwinckover 9 years ago
I was given this exact problem at a Google interview. In fact it was virtually the only high level, real code programming exercise I was asked to do in many hours of interviews.
评论 #10722624 未加载
bschwindHNover 9 years ago
For those of us not particularly skilled at Haskell, could you add some comments on the actual code, or at least explain some of the lines? I get the English part of the algorithm, but I don&#x27;t think I&#x27;m up to speed on some of the syntax being used in your solutions.
评论 #10722690 未加载
评论 #10722582 未加载
评论 #10723343 未加载
eruover 9 years ago
I wrote a really nice merge function (in Haskell) when I helped a friend prepare for an interview. Perhaps I should send it to the author.
heinrich5991over 9 years ago
I believe integer sorting doesn&#x27;t have a lower bound of O(n log n), because you can do more with them than just comparing.
评论 #10722649 未加载
评论 #10723356 未加载