Masalalar
Go Algoritm masala

Div taglar hosil qilish

19 September, 2026
Go
package main

func (_ Solution) GenerateDivTags(numberOfTags int) []string {
	
  result := []string{}

  var recursiveFunc func(string, int, int)

  recursiveFunc = func(current string, open int, close int){
    if open == numberOfTags && close == numberOfTags {
      result = append(result, current)
      return
    }

    if open < numberOfTags {
      recursiveFunc(
        current + "<div>",
        open + 1,
        close,
      )
    }
    if close < open {
      recursiveFunc(
        current + "</div>",
        open,
        close + 1,
      )
    }
  }
  recursiveFunc("", 0, 0)
	return result
}

Rekursiya boyicha masala ishlaymiz. Rekursiya haqida

👍 0 ❤️ 1 🔥 0

Izohlar 0

Izoh qoldirish uchun kiring yoki ro'yxatdan o'ting.

Hali izoh yo'q. Birinchi bo'ling!