- PVSM.RU - https://www.pvsm.ru -
Мы отобрали вопросы и задачи, встречающиеся соискателям на собеседованиях в ведущие ИТ-компании мира.
В подборку попали задачи, задаваемые на собеседованиях должность инженера-разработчика. Задачи различного уровня сложности, начиная от простых. Предлагаем Вам попробовать свои силы и постараться решить задачи самостоятельно — тогда вопросы на собеседовании вряд ли застанут Вас врасплох.
A man has a medical condition that requires him to take two kinds of pills, call them A and B. The man must take exactly one A pill and exactly one B pill each day. The pills are taken by first dissolving them in water.
The man has a jar of A pills and a jar of B pills. One day, as he is about to take his pills, he takes out one A pill from the A jar and puts it in a glass of water. Then he accidentally takes out two B pills from the B jar and puts them in the water. Now, he is in the situation of having a glass of water with three dissolved pills, one A pill and two B pills. Unfortunately, the pills are very expensive, so the thought of throwing out the water with the 3 pills and starting over is out of the question. How should the man proceed in order to get the right quantity of A and B while not wasting any pills?
У больного есть склянка с А и склянка с Б. Однажды он, растворив таблетку А в стакане, бросил туда 2 таблетки из склянки с Б и получил стакан с раствором из 1 А и 2 Б. К сожалению, лекарства дорогие, поэтому он отбросил мысль вылить этот раствор и приготовить новый. Как этому больному продолжить приём назначенных лекарств, не потеряв при этом ни таблетки?
Three Employees want to know average of their salaries. They are not allowed to share their individual salaries. How can they calcalate average salary?
Given a natural number n, write a program to find the number of ways in which n can be expressed as a sum of natural numbers when order is taken into consideration. Two sequences that differ in the order of their terms define different compositions of their sum.
Examples:
Input: 4
Output: 8
Explanation
All 8 position composition are:
4, 1+3, 3+1, 2+2, 1+1+2, 1+2+1, 2+1+1 and 1+1+1+1Input: 8
Output: 128
Примеры:
Вход: 4
Выход: 8
Объяснение: 4, 1+3, 3+1, 2+2, 1+1+2, 1+2+1, 2+1+1 и 1+1+1+1
Given a number n, write a function that returns count of numbers from 1 to n that don’t contain digit 3 in their decimal representation.
Examples:
Input: n = 10
Output: 9Input: n = 45
Output: 31
// Numbers 3, 13, 23, 30, 31, 32, 33, 34,
// 35, 36, 37, 38, 39, 43 contain digit 3.Input: n = 578
Ouput: 385
Примеры:
Вход: n = 10
Выход: 9
Вход: n = 45
Выход: 31
// Числа 3, 13, 23, 30, 31, 32, 33, 34,
// 35, 36, 37, 38, 39, 43 содержат 3.
Вход: n = 578
Выход: 385
Write a program according with following specifications:
Input: A array arr[] of two elements having value 0 and 1
Output: Make both elements 0.Requirements: Following are the specifications to follow.
1) It is guaranteed that one element is 0 but we do not know its position.
2) We can’t say about another element it can be 0 or 1.
3) We can only complement array elements, no other operation like and, or, multi, division, …. etc.
4) We can’t use if, else and loop constructs.
5) Obviously, we can’t directly assign 0 to array elements.
Вход: массив arr[] из 2-х элементов, имеющих возможные значения 1 или 0
Выход: Сделать оба элемента равными 0
Требования:
1) Известно, что один элемент равен 0, но неизвестна его позиция
2) Про второй элемент мы этого не можем сказать, он может быть 0 или 1.
3) Мы можем только дополнять элементы массива, никакие другие операции, такие как or, and, умножение, деление и др. не разрешены.
4) Нельзя использовать условные конструкции, циклы.
5) Нельзя явно записать 0 в элементы массива.
Ответы будут даны в течение следующей недели — успейте решить. Удачи!
Автор: reci
Источник [1]
Сайт-источник PVSM.RU: https://www.pvsm.ru
Путь до страницы источника: https://www.pvsm.ru/programmirovanie/274437
Ссылки в тексте:
[1] Источник: https://habrahabr.ru/post/350300/?utm_campaign=350300
Нажмите здесь для печати.