NeuralHack Stage 2 Python
NeuralHack Stage 2 Python
Professor X wants to send the longest message possible to his friend.To do this, he can stop
the machine at any point and transmit the message by pressing the send button.However he can do
this only when the machine is in the recording mode and not the erasing mode.He wants your help.
Given the input string, your task is to find the longest possible message that can be delivered
by the machine.If there is more that one longest possible message, find the message which is nearer
to the end of the string.
Given an array of “n” integer numbers A(1)…..A(n), determine all contiguous subsequences
A(i)……A(j) of positive numbers.Write a function to find the sum of elements in each sub sequence and
output the maximum sum value.
Input2: An integer array where elements range between {-10000 <= A(i) <= 10000}
Output:
Example 1:
Input1 : 5
Input2 : [1,2,4,-2,3]
Output : 7
Explanation:
Here the contiguous sub sequences are {1,2,4} and {3}. The max sum of these sequences is 7.
Example 2:
Input1:5
Input2: [1,2,-3,4,-5]
Output: 4
Explanation:
Here the contiguous sub sequences are {1,2} and {4}. The max sum of these sequences is 4.
3)Bit reverse:
Given a 32 bit signed integers, write a function to return the integer formed by reversing its
bits.
Input:
Output:
Example 1:
Input1: 2
Output: 1073741824
Explanation:
The 32 bit equivalent of 2 is 00000000 00000000 00000000 00000010. On reversing its bits we
get 01000000 00000000 00000000 00000000 which is the binary quivalent of 1073741824.
Example 2:
Input1 : 1
Output: -2147483648
Explanation:
The 32 bit equivalent of 1 is 00000000 00000000 00000000 0000001. On reversing its bits we
get 10000000 00000000 00000000 00000000 which is the binary quivalent of -2147483648.