- PVSM.RU - https://www.pvsm.ru -
Подоспел очередной выпуск ITренировки — задач, предлагаемых на собеседования в ведущие IT-компании.

В подборку вошли задачи и вопросы от Facebook, которые задают желающим устроиться на должность разработчика. Традиционно, отобраны как простые задачи, так и не очень. Рекомендуем попробовать решить задачи самостоятельно, ссылку на оригинальные решения мы обычно добавляем в секцию ответов.
People are waiting in line to board a 100-seat airplane. Harry is the first person in the line. Harry gets on the plane but he forgets his seat number, so he picks a seat at random. After that, each person who gets on the plane sits in his assigned seat if it’s available otherwise chooses an open seat at random to sit in. The flight is full and you are last in line. What is the probability that you get to sit in your assigned seat?
Measure 9 minutes from a 4 minutes hourglass and a 7 minutes hourglass.
Given a dictionary, a method to do lookup in dictionary and a M x N board where every cell has one character. Find all possible words that can be formed by a sequence of adjacent characters. Note that we can move to any of 8 adjacent characters, but a word should not have multiple instances of same cell.
Example:
Input: dictionary[] = {«HABR», «FOR», «QUIZ», «GO»};
boggle[][] = {{'H','I','Z'},
{'U','A','R'},
{'Q','N','B'}};isWord(str): returns true if str is present in dictionary
else false.Output: Following words of dictionary are present
HABR
QUIZ
Пример:
Вход: dictionary[] = {«HABR», «FOR», «QUIZ», «GO»};
boggle[][] = {{'H','I','Z'},
{'U','A','R'},
{'Q','N','B'}};
isWord(str): возвращает true если слово str есть в словаре, иначе — false.
Выход: Следующие слова наличествуют в словаре:
HABR
QUIZ
A top secret message containing letters from A-Z is being encoded to numbers using the following mapping:
'A' -> 1
'B' -> 2
…
'Z' -> 26You are an FBI agent. You have to determine the total number of ways that message can be decoded.
Note: An empty digit sequence is considered to have one decoding. It may be assumed that the input contains valid digits from 0 to 9 and If there are leading 0’s, extra trailing 0’s and two or more consecutive 0’s then it is an invalid string.Example:
Given encoded message «123», it could be decoded as «ABC» (1 2 3) or «LC» (12 3) or «AW»(1 23).
So total ways are 3.
'A' -> 1
'B' -> 2
…
'Z' -> 26
Вы агент РКН ФБР. Вам необходимо определить количество вариантов расшифровки этого сообщения. Прим.: пустая числовая последовательность считается имеющей один вариант. Предполагается, что входная строка имеет корректную последовательность чисел 0-9. Если есть ведущие 0 или лишние замыкающие 0, а также два и более повторяющихся 0 — такая строка некорректна.
Пример:
Зашифрованное сообщение — «123», оно может быть расшифровано как «ABC» (1 2 3) или «LC» (12 3) или «AW»(1 23).
Ответ: 3.
Given two numbers as stings s1 and s2, your task is to multiply them. You are required to complete the function multiplyStrings which takes two strings s1 and s2 as its only argument and returns their product as strings.
Constraints:
1<=length of s1 and s2 <=100Input: s1 = 4154
s2 = 51454
Output: 213779916Input: s1 = 654154154151454545415415454
s2 = 63516561563156316545145146514654
Output: 41549622603955309777243716069997997007620439937711509062916
Ограничения:
1 <= длина s1 и s2 <= 100
Пример:
Вход: s1 = 4154
s2 = 51454
Выход: 213779916
Вход: s1 = 654154154151454545415415454
s2 = 63516561563156316545145146514654
Выход: 41549622603955309777243716069997997007620439937711509062916
Ответы будут даны в течение следующей недели — успейте решить. Удачи!
Автор: Андрей
Источник [1]
Сайт-источник PVSM.RU: https://www.pvsm.ru
Путь до страницы источника: https://www.pvsm.ru/programmirovanie/279817
Ссылки в тексте:
[1] Источник: https://habr.com/post/358064/?utm_source=habrahabr&utm_medium=rss&utm_campaign=358064
Нажмите здесь для печати.