Leetcode with dani – Telegram
Leetcode with dani
1.31K subscribers
196 photos
14 videos
56 files
240 links
Join us and let's tackle leet code questions together: improve your problem-solving skills
Preparing for coding interviews
learning new algorithms and data structures
connect with other coding enthusiasts
Download Telegram
Forwarded from 「 Eyu core 」
🔥8
Woow
21
መልካም የመስቀል በዓል ይሁንላችሁ
10👍1💋1
new feature
😭
😁8😭4
i wrote a code and submitted it but when i looked at it, it always returned True then i wrote this and submitted it and it worked, i didnt expect this answer for DP question😂😂
🤣9😁2
Amazing 🥳
15🎉3
6
this question freaks me out 🥵 i coundnt pass the time constraint
Leetcode with dani
this question freaks me out 🥵 i coundnt pass the time constraint
n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
bu = [0] * n
for i in range(len(arr) - 2, -1, -1):
bu[i] = abs(arr[i] - arr[i + 1]) + bu[i + 1]
for j in range(i + 2, min(i + k + 1, len(arr))):
bu[i] = min(abs(arr[i] - arr[j]) + bu[j], bu[i])

print(bu[0])
💯
7🔥1