Đến nội dung

adm

adm

Đăng ký: 20-05-2017
Offline Đăng nhập: 29-05-2018 - 21:15
-----

Hỏi 1 chút về thuật toán lập trình

20-05-2017 - 23:19

Giả sử em là một tên trộm chuyên đi cắp đồ. em có một dãy số là số tiền trong từng nhà ở một khu dân cư và chuẩn bị đi chôm. Và em biết rằng nếu đi chôm 2 nhà liền kề nhau thì chuông báo động sẽ kêu. Hỏi cách nào để chôm được nhiều tiền nhất ạ

Bài toán nguyên văn tiếng Anh:

You are planning to rob houses on a specific street, and you know that every house on the street has a certain amount of money hidden. The only thing stopping you from robbing all of them in one night is that adjacent houses on the street have a connected security system. The system will automatically trigger an alarm if two adjacent houses are broken into on the same night.

Given a list of non-negative integers nums representing the amount of money hidden in each house, determine the maximum amount of money you can rob in one night without triggering an alarm.

Em cảm ơn ạ