TGStat
TGStat
Type to search
Advanced channel search
  • flag English
    Site language
    flag Russian flag English flag Uzbek
  • Sign In
  • Catalog
    Channels and groups catalog Regional compilations Thematic compilations Платные каналы Search for channels
    Add a channel/group
  • Ratings
    Rating of channels Rating of groups Posts rating
    Ratings of brands and people
  • Analytics
  • Search by posts
  • Telegram monitoring
  • Promotion
    Advertising through Yandex Business Advertising in channels through TGStat Agency Advertising on TGStat.ru website
𝚂𝚗𝚘𝚠𝙱𝚊𝚕𝚕𝙲𝚘𝚍𝚎

6 Aug, 12:34

Open in Telegram Share Report

Литкод задачки с решением на Swift ч.3:

🐬 Climbing Stairs: тебе нужно подняться на вершину лестницы, у которой n ступенек. Каждый раз ты можешь подняться на 1 или на 2 ступеньки. Сколько существует различных способов подняться наверх?

// Примеры
Input: n = 2 → 2
// 1. 1 + 1
// 2. 2

Input: n = 3 → 3
// 1. 1 + 1 + 1
// 2. 1 + 2
// 3. 2 + 1

Input: n = 4 → 5

Объяснение и решение: Это классическая задача на динамическое программирование (почти числа Фибоначчи)
dp[i] = количество способов добраться до i-й ступеньки
dp[i] = dp[i-1] + dp[i-2]

class Solution {
func climbStairs(_ n: Int) -> Int {
if n Bool {
guard s.count == t.count else { return false }

var counter = [Character: Int]()

for char in s {
counter[char, default: 0] += 1
}

for char in t {
guard let count = counter[char], count > 0 else { return false }
counter[char] = count - 1
}

return true
}
}

Эти две задачи тоже легко решаются примерно за 20 минут и отлично развивают мышление (динамика + хеш-таблица)
😍
🥰 @SnowBallCode
😍

331 0 1 3
Catalog
Channels and groups catalog Channels compilations Search for channels Add a channel/group
Ratings
Rating of Telegram channels Rating of Telegram groups Posts rating Ratings of brands and people
API
API statistics Search API of posts API Callback
Our channels
@TGStat @TGStat_Chat @telepulse @TGStatAPI
Read
Академия TGStat Telegram Research 2019 Telegram Research 2021 Telegram Research 2023
Contacts
Справочный центр Support Email Jobs
Miscellaneous
Terms and conditions Privacy policy Public offer
Our bots
@TGStat_Bot @SearcheeBot @TGAlertsBot @tg_analytics_bot @TGStatChatBot