Harry loves numbers in the range [m1, m2] (m1 and m2 included). carry decides to gift harry an array of numbers for his birthday. harry wants to find the number of pairs of indices [l, r] for which the sum of all the elements in the range [l, r] lies between m1 and m2.
Come up with an algorithm with a worst case complexity of O(N2).
Now improvise this algorithm, assuming all numbers are positive integers.
What if the numbers could be negative as well? Can you think of an O(nlogn) solution in this case? (Hint: use sorting)
Using binary, find the element of Key 10 in the following array.
10,14,19,26,27,31,33,35,42,44
Harry loves numbers in the range [m1, m2] (m1 and m2 included). carry decides to gift harry an array of numbers for his birthday. harry wants to find the number of pairs of indices [l, r] for which the sum of all the elements in the range [l, r] lies between m1 and m2.
Viva (Delivery Milestone) Configure a system to allow files to be shared amongst Linux computers. Create three shares: one called Cheese that is read only and restricted to the 192.168.1.0/24 network, one called Pickle with read write access, that permits root privileges and can only be accessed from 192.168.1.1 and one called Crackers that is accessible to 192.168.1.1/24 to 192.168.1.10/24 as read write and everyone else as read only. Ensure that all of these files are shared across an array of 2 disks for reliability. Where additional data may be needed to complete this task, generate this using judgement.
Split an original single linked list into two sub-lists, where the first and second sub-list contains the even position nodes and odd position nodes of the original list respectively, and then join the second sub-list at the end of the first sub-list. Example: If the list contains 3->4->2->1->7->9->8, then the function needs to produce 3->2->7->8->4->1->9.
pairs = [ (x,y) for x in range(5,1,-1) for y in range(4,1,-1) if (x+y)%3 == 0 ]