- PVSM.RU - https://www.pvsm.ru -
Подоспел очередной выпуск ITренировки, и сегодня в номере — задачи от интервьюеров Microsoft.
В подборку вошли задачи с собеседований Microsoft. Сложность, традиционно, варьируется от простых до таких, над которыми нужно немного поразмыслить. Мы предпочитаем делать это в спокойной обстановке, нежели в цейтноте на собеседовании, и желаем, чтобы Ваши собеседования проходили так же спокойно, расслабленно и конструктивно :)
There is an 8 by 8 chessboard in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board?
You’ve got someone working for you for seven days and a gold bar to pay them. You must pay the worker for their work at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker? (Assuming equal amount of work is done during each day thus requiring equal amount of pay for each day)
Given pointer to the head node of a linked list, the task is to reverse the linked list. We need to reverse the list by changing links between nodes.
Examples:
Input: Head of following linked list
1->2->3->4->NULL
Output: Linked list should be changed to,
4->3->2->1->NULLInput: Head of following linked list
1->2->3->4->5->NULL
Output: Linked list should be changed to,
5->4->3->2->1->NULLInput: NULL
Output: NULLInput: 1->NULL
Output: 1->NULL
Примеры:
Вход: Указатель на головную ноду, и сам список — 1->2->3->4->NULL
Выход: 4->3->2->1->NULL
Вход: 1->2->3->4->5->NULL
Выход: 5->4->3->2->1->NULL
Вход: NULL
Выход: NULL
Вход: 1->NULL
Выход: 1->NULL
Given an array arr[0 … n-1] containing n positive integers, a subsequence of arr[] is called Bitonic if it is first increasing, then decreasing. Write a function that takes an array as argument and returns the length of the longest bitonic subsequence.
A sequence, sorted in increasing order is considered Bitonic with the decreasing part as empty. Similarly, decreasing order sequence is considered Bitonic with the increasing part as empty.Examples:
Input arr[] = {1, 11, 2, 10, 4, 5, 2, 1};
Output: 6 (A Longest Bitonic Subsequence of length 6 is 1, 2, 10, 4, 2, 1)Input arr[] = {12, 11, 40, 5, 3, 1}
Output: 5 (A Longest Bitonic Subsequence of length 5 is 12, 11, 5, 3, 1)Input arr[] = {80, 60, 30, 40, 20, 10}
Output: 5 (A Longest Bitonic Subsequence of length 5 is 80, 60, 30, 20, 10)
Пример:
Вход: arr[] = {1, 11, 2, 10, 4, 5, 2, 1};
Выход: 6 (Длина наибольшей битонной подпоследовательности — 6 { 1, 2, 10, 4, 2, 1})
Вход: arr[] = {12, 11, 40, 5, 3, 1}
Выход: 5 (12, 11, 5, 3, 1)
Вход: arr[] = {80, 60, 30, 40, 20, 10}
Выход: 5 (80, 60, 30, 20, 10)
Given a string, move all even positioned elements to end of string. While moving elements, keep the relative order of all even positioned and odd positioned elements same with O(1) space and O(n) time.
In other words given a string with alternating elements (numbers and letters) like this [a1b2c3d4] should be converted to [abcd1234].
Ответы будут даны в течение следующей недели — успейте решить. Удачи!
Автор: reci
Источник [1]
Сайт-источник PVSM.RU: https://www.pvsm.ru
Путь до страницы источника: https://www.pvsm.ru/programmirovanie/277571
Ссылки в тексте:
[1] Источник: https://habrahabr.ru/post/352964/?utm_campaign=352964
Нажмите здесь для печати.