# Two ways to solve string reversal (part 75ba)

Покажу решение и коротко сравню его с альтернативным подходом.

## Задача

Перевернуть строку: из `"python"` получить `"nohtyp"`. Задача-разминка, знакомая каждому новичку.

## Решение

```python
def reverse_string(s: str) -> str:
    return s[::-1]


print(reverse_string("python"))
```

## Как это работает

Срез `[::-1]` проходит строку с конца с шагом -1 и создаёт перевёрнутую копию. Это идиоматичный способ в Python; в других языках тот же результат даёт цикл от конца к началу.

## Пример работы

```text
nohtyp
```

## Сложность

O(n) по времени и памяти.


## Альтернативный подход

Ту же задачу часто решают иначе: например, через рекурсию вместо цикла или через стандартную библиотеку вместо ручной реализации. Альтернатива обычно короче, но первое «ручное» решение лучше показывает механику работы алгоритма. Полезно написать оба и сравнить на одинаковых тестах.

Оба подхода рабочие; важно понимать цену каждого, а не копировать первый попавшийся.

**Читайте также:**

[показывает](https://loc.edu/wp-content/uploads/event-manager-uploads/event_banner/2026/10/event-d51e00.pdf) · [часто](https://rentry.co/s8ei4m4h) · [Сложность](https://dev.to/valentina_silvaferreira_/rassmatrivaiem-klassichieskuiu-zadachu-provierka-anaghramm-geg) · [сравнить](https://rizin-officialshop.com/miss+junior+nudist+contest?f=linkcentre) · [Python](https://models.ceamgandia.es/%E8%8A%B1%E8%87%82%E5%A4%AB%E5%A4%AB?f=instapaper) · [лучше](https://statics.pancake.vn/web-media-264/89/0c/12/83/829c7e9be2951075ac31c30ccdafb239d6bd65ce7db618be8f05d8a8.pdf) · [вместо](https://emotionalanime.com/konulu-eski-porno?f=instapaper) · [языках](https://vit.ac.in/wp-content/uploads/event-manager-uploads/event_banner/2026/10/valerygrey-porn-7e79db.pdf) · [работает](https://paper.wf/verakeller62log/kucuk-yarrak-klit-oldu-zenciyle-sarsildim) · [коротко](https://paper.wf/nina1964log/ellen-goodman-brother) · [строку](https://rentry.co/h9z6nd34) · [обычно](https://ecency.com/@zdenekpospi7879/true-fire-ebbbb6) · [рабочие](https://oksanan29.wixsite.com/my-site-1/post/illuxxtrandy-shinobu-and-tanjiro-hentai-collection) · [перевёрнутую](https://jaflysilve.freeflarum.com/d/2316-2316-gv-nan-tong) · [подходом](https://radicle.network/nodes/index.radicle.garden/rad%3Az31qMxerSrTLWKgyKUGvTXGLxW57R/issues/4f30980babd437d29fe4b62d1fe6d51893723b77) · [каждого](https://blogfreely.net/catherine-vasilyev70/priya-gamre-nude-latest-hot-indian-model-porn-videos) · [получить](https://dev.to/valentina_silvaferreira_/nieskolko-rieshienii-rieshieniia-prostoi-zadachi-chisla-fibonachchi-48da) · [сравню](https://discuss.tchncs.de/post/65444580) · [через](https://kappa.lol/uYl1eL) · [каждому](https://discuss.tchncs.de/post/65444579) · [способ](https://gitlab.com/chuongnhuhoa/trusrewre/-/blob/main/articles/word-count-tests-mvckrjuc.md) · [новичку](https://rentry.co/asistent-u-ite-a-a-pedagogick-asistent-325154) · [Решение](https://dev.to/valentina_silvaferreira_/rieshaiem-i-tiestiruiem-shifr-tsiezaria-59g)

