Hamiltonian Cycle
July 27, 2020Bilgisayar temizliği ve organizasyonu işlerine bulaştım. Arşivimden çıkan bir problemi paylaşmak istiyorum.
Kim olduğunu hatırlamamakla beraber IBM olabilir, kodlama mülakatında aşağıdaki problemi sormuştu.
Size N elemanlı bir string dizisi veriliyor. Sizin amacınız ise her kelimenin son harfinin bir sonraki kelimenin ilk harfi olacak şekilde N elemanlı bir döngü bulmanız ve bu döngüyü cevap olarak ekrana bastırmanız.
|
|
Bu problem literatürde hamiltonian cycle olarak geçiyor. Bir vertexten başlayıp tüm vertexleri sadece bir defa gezerek başladığınız noktaya geliyorsanız buna hamilton cycle deniyor.
Mülakat sırasında doğru implementasyonu yapamamıştım. Backtracking kısmını unuttuğum için segfault alarak elenmeyi garantiledim.
Mülakattan sonra salim kafayla oturup tekrar çözdüm. Basitçe dfs + backtracking ile çözülüyormuş. Açıklamaları comment olarak ekledim.
|
|
hidden
The Review Is the Action Item
2024/05/30The Review Is the Action ItemI like to consider running an incident review to be its own action item. Other follow-ups emerging from it are a plus, but the point is to learn from incidents, and the review gives room for that to happen.This is no…
via Ferd.caFinding a New Software Developer Job
For the first time ever, I was laid off, and had to find a new software developer job. I managed to find a new one, but it took longer than I thought, and it was a lot of work. I … Continue reading →
via Henrik Warne's blogHOWTO: Change your behavior
In theory, behavior change should be easy. At first glance, it seems like you control your behavior. So, if you desire different behavior, why doesn’t your behavior change as instantly as your desire to change it? In short, lasting change of habitual behavio…
via Matt Might's blog