Tuesday 17 November 2020

Easy Problem Links in Hacker Earth

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/jump-out-34/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/easy-multiple/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/good-string-3/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/title-abhi-socha-nahi/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/palindromic-numbers-7/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/step-up-0aa9708f/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/cheapest-subarray-d628cb65/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/brick-and-building-26cc28f2/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/techfest-and-group-photo-06dfebc0/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/easy-multiples/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/counting-rr/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/prime-string-598/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/roys-life-cycle-44/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/fredo-and-game/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/roys-life-cycle/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/recursive-sums/

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/coin-game-3-1762eeeb/

Monday 9 November 2020

python program to store the first 100 prime numbers excluding 2 in an array using sieve of Eratosthenes

 

pf=[1]

def gp(n):

               pr = [1 for i in range(n + 1)]

               p = 2

               while (p * p <= n):

                              if (pr[p] == 1):

                                             for i in range(p * 2, n + 1, p):

                                                            pr[i] = 0

                              p = p + 1

               pr[0]= 0

               pr[1]= 0

               pr[2]= 0

 

               for p in range(n + 1):

                              if pr[p]:

                                             pf.append(p)

gp(541)

print(pf)

Sunday 8 November 2020

Replace every element of the array by product of all other elements

Replace every element of the array by product of all other elements

 For example : Consider an array as shown below


If you want to implement the above logic using O(n) space, you can do it only using recursion.

Solution can be found at

https://www.techiedelight.com/replace-element-array-product-every-element-without-using-division-operator/


Recursion tree is as follows