Posts

Question Set 3

This is question set 3. Another day another set.Happy Coding! "Talk is Cheap Just code it" Problem 1-Kadane's Algorithm(Easy) Given an integer array ,  find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.    SAMPLE INPUT   -2 1 -3 4 -1 2 1 -5 4  SAMPLE OUTPUT    6 [4+(-1)+2+1] Link to the question- https://leetcode.com/problems/maximum-subarray/ Problem 2-GCD(Easy) GCD (Greatest Common Divisor) or HCF (Highest Common Factor) of two numbers is the largest number that divides both of them.Find the GCD of two numbers. PS-Try to learn Euclid method of calculating GCD   SAMPLE INPUT   a=96 b=56 SAMPLE OUTPUT   14 Link to the question- https://www.geeksforgeeks.org/c-program-find-gcd-hcf-two-numbers/    Problem 3-GCD of Array(Easy) Given an array of numbers, find GCD of the array elements. SAMPLE INPUT   2 4 6 8    SAMPLE OUTPUT   2 ...

Question Set 2

This is question set 2. This set has some implementation problems and try submitting them on different platforms.This will help you get familiar with coding platforms. Problem 1-Watermelon(Easy) One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed  w  kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. The first (and th...