GOLANG_INTERVIEW Telegram 341
💡Задача: Префиксное дерево

Условие : префиксное дерево - это структура данных для эффективного хранения и извлечения ключей в массиве строк.

Необходимо реализовать класс со следующими методами:

- Trie() - инициализатор;
-
void insert(String word) - осуществляет вставку в экземпляр класса;
- boolean search(String word) - возвращает флаг о наличии слова word в дереве;
- boolean startsWith(String prefix) - возвращает флаг о том, начинается ли слово, вставленное на предыдущем шаге с prefix.

Пример:

Ввод:
["Trie", "insert", "search", "search", "startsWith", "insert", "search"]
[[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]]

Вывод: [null, null, true, false, true, null, true]

Объяснение:
Trie trie = new Trie();
trie.insert("apple");
trie.search("apple"); // return True
trie.search("app"); // return False
trie.startsWith("app"); // return True
trie.insert("app");
trie.search("app"); // return True

Решение

Пишите свое решение в комментариях👇

@golang_interview
Please open Telegram to view this post
VIEW IN TELEGRAM
👍8🔥2🥰21



tgoop.com/golang_interview/341
Create:
Last Update:

💡Задача: Префиксное дерево

Условие : префиксное дерево - это структура данных для эффективного хранения и извлечения ключей в массиве строк.

Необходимо реализовать класс со следующими методами:

- Trie() - инициализатор;
-
void insert(String word) - осуществляет вставку в экземпляр класса;
- boolean search(String word) - возвращает флаг о наличии слова word в дереве;
- boolean startsWith(String prefix) - возвращает флаг о том, начинается ли слово, вставленное на предыдущем шаге с prefix.

Пример:

Ввод:
["Trie", "insert", "search", "search", "startsWith", "insert", "search"]
[[], ["apple"], ["apple"], ["app"], ["app"], ["app"], ["app"]]

Вывод: [null, null, true, false, true, null, true]

Объяснение:
Trie trie = new Trie();
trie.insert("apple");
trie.search("apple"); // return True
trie.search("app"); // return False
trie.startsWith("app"); // return True
trie.insert("app");
trie.search("app"); // return True

Решение

Пишите свое решение в комментариях👇

@golang_interview

BY Golang вопросы собеседований




Share with your friend now:
tgoop.com/golang_interview/341

View MORE
Open in Telegram


Telegram News

Date: |

Among the requests, the Brazilian electoral Court wanted to know if they could obtain data on the origins of malicious content posted on the platform. According to the TSE, this would enable the authorities to track false content and identify the user responsible for publishing it in the first place. Avoid compound hashtags that consist of several words. If you have a hashtag like #marketingnewsinusa, split it into smaller hashtags: “#marketing, #news, #usa. Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day. Some Telegram Channels content management tips
from us


Telegram Golang вопросы собеседований
FROM American