TechoSagar: 2017

What is the best strategy to improve my skills in competitive programming in 2-3 months?

                   

                                

By

Viktória Nemkin, studies software engineering at Budapest University of Technology and Economics.


This sounds off topic but please bear with me for a moment. What I struggle with a lot is essentially not doing what I know I should and want to be doing. My mind is not focused, I go watch a stupid video on youtube and the whole day is gone. It is really hard for me to get myself going. I don't know you, I don't know if you have the same struggles as I do but maybe some of this advice will help you stay focused if you need it.
Here are a few things I've learnt about doing competitive stuff:
  • You don't have to and you really shouldn't overwhelm yourself on the first time. Don't go to the bookstore and buy the heaviest, biggest book on Computer Science only to read the first few pages and realize you don't understand it and give up. I'm guilty of doing this a lot. Instead, try to find something that is not so into detail and easier to wrap your head around it. In the next steps I try to recommend you easy to understand tutorials online.
  • Don't wait to get motivated. I find this advice really good because it is a great insight to how your mind actually works. I'm sure there are a few lucky people to whom this doesn't apply but for the rest of us, we are not going to feel like studying and practicing all the time. There will be days when we will get bored doing it. There will be days when we will want to go do other fun things. What makes successful people different from everybody else is that they can handle the boredom of doing the things they want to be doing for a long time. (I've read this here: How to Stay Focused When You Get Bored Working Toward Your Goals .)
  • Don't try to completely change your schedule and study and practice in all of your free time. Completely changing everything is really hard and can easily overwhelm you and make you give up. Just like trying to get down to a healthy weight by eating 500 calories a day. You just can't stick to it in the long run. Instead, go for small changes, but do them regularly.
  • Don't let other people's success demotivate you. You know how they say no matter how good you are, there is an Asian kid who is better than you? I'm no IOI medalist. I did compete in the country level qualifiers to get out but no success. I see famous people answering questions here on Quora and I'm really not one of them. But really, who cares? Feel proud of what you have accomplished so far and instead of comparing yourself to everybody else, try to outdo yourself. Generally, a lot of hard working famous people are also very humble and they will tell you they had their moments of giving up, failing and feeling bad about themselves. You only see their success but not how they got there.
I hope this advice helps you stay on track. Now to the more technical stuff.
Knowledge in theory of algorithms and data structures
I started practicing for competitive programming with my teacher in school, the first few things we learnt were:
I think that's basically all I knew when I first competed. Probably other people will tell you a lot of other things, this is just how I started out.
Later, you can find a book that works for you and you can read it or watch an online course to get into the topic more deeply.
Here are some examples:
A programming language
I like C++. It is fast, it has its Standard Template Library with plenty of cool stuff. For example if you need a good sorting algorithm you can just include the algorithm library and use one function. It is really useful because you don't want to waste your time on a competition to implement basic things like data structures and basic algorithms.
Some tutorials on STL:
And the reference site I use: cplusplus.com
Look up some Containers like vectorliststackqueue and the sortalgorithm I talked about.
Some argue that C/C++ are the only reasonable programming languages for competitive programming. I would say if you don't really like C, go for a high level language. It's better to be comfortable with the platform than to be miserable with C. A lot of good competitors use Java, and they say it is not a drawback for them. Look up similar libraries for your choice of language and try using them!
Practice, practice, practice. A lot.
It's one thing that you know how to solve stuff in theory. It's a completely different thing that you can code it, it compiles and runs, gives no errors, you made sure all variables are big enough so they will fit, it is fast enough and doesn't use too much memory.
You need to go sit down and solve exercises for yourself to be able to do it fast and with no errors on stage. When I'm out of practice I spend 10 minutes debugging a binary search because I just can't write it for the first time. It's not good to spend 10 minutes of your competition writing a binary search.
So doing exercises, not just in theory but finishing them with a tested, working code is really great for you.
Here are a few sites that host online competitions regularly:
What's really great about these sites that you can post your code and they will test and score you for all the previous competitions. Even better, you can see what others have sent in. You can learn a lot from other people's codes. I've heard that some guys on Codeforces spend weeks optimizing their code, so they run faster than anybody else's.
If you check previous competitions on these sites, usually the first few problems in each of them are easy to solve and are aimed for beginners.
I hope this answer helps you get started. :)

Published after taking permission from author .

Thanks  Viktória Nemkin

Honda Yes Awards



Click Here to apply 

We have started the Y-E-S Award program for fostering future leaders in the field of science and technology. Following the start-up of the award program in Vietnam in 2006, in India in 2007 and in Laos and Cambodia in 2008, it was introduced in Myanmar in 2014 to support the development and promotion of young leaders to spearhead the growth of these countries in the future.
This system grants awards to students who have excelled in the area of science and technology and who continue to aspire to higher academic achievement. However, it is distinctive in that it is not restricted to tuition but may be used for a broad range of activities. Furthermore, the grant is awarded in two stages. Another very unique characteristic of the system is that its details are matched to the receiving country's needs and circumstances; it is set up to be flexible to each country's needs.
The program hopes to promote dissemination of ecotechnology among the young generations and at the same time to strengthen interaction and exchange between Japanese youths and young people expect to lead science, technology and industry in their respective countries.


Benefits

Stage I : The Y-E-S Award
The Award would recognise brilliant students who would drive future society towards an ecotechnological orientation.
Each Y-E-S Award recipient will receive US$ 3,000 (US Dollar Three Thousand only) in equivalent Indian Rupees.
Stage II: Y-E-S Award Plus
Every Y-E-S Award recipient becomes eligible for the Y-E-S Award Plus, an additional award, if, within three years after he/she received the Y-E-S Award prize, he/she is 
admitted to, and pledges to attend within one year after admission, either of the following:










India Innovation Challenge Design Contest 2017




Texas Instruments in collaboration with Department of Science and Technology (DST) proudly announce the DST & Texas Instruments India Innovation Challenge Design Contest 2017 anchored by NSRCEL, Indian Institute of Management, Bangalore (IIMB) and supported by MyGov. The contest is open for all Indian engineering students pursuing undergraduate, postgraduate&Doctoral degrees with Indian engineering colleges.
Texas Instruments (TI) invites all student innovators, thinkers and makers of the country to join the revolution, who have a dream to create something new, aspire to make a difference, contribute to India’s success towards becoming an Innovation Hub and strengthen Make in India Program.
Give your ideas a jump-start by sculpting your innovation with technical support from Texas Instruments, business mentorship from IIMB, funding and prizes of INR 3.8 crores from DST& TI

ELIGIBILITY CRITERIA

  • The contest is open for all Indian engineering students pursuing undergraduate, postgraduate&Doctoral degrees with Indian engineering colleges.
  • All the participants must be Indian Nationals
  • TI will be providing TI tools worth up to USD 200 for each team free of cost. You must use all TI devices in your solution.
For more Details Visit https://innovate.mygov.in/india-innovation-challenge-design-contest-2017/   

Analyze This 2017.



 Analyze This 2017.



Wanna join Amex?

Here is your opportunity

American Express Campus is excited to present its Flagship Data Analytics Competition - #Analyze This 2017.
Winners and top performers from each campus win a direct PPI with American Express and prizes worth INR 2,50,000 !!!
1st Prize: I-pad
2nd Prize: GoPro Camera
3rd Prize: Bluetooth Speaker
And much more…
Registration opens: 17th August, 10:00 am

Maximum Integer Value

Company:  Facebook
Given a string of numbers, the task is to find the maximum value from the string, you can add a ‘+’ or ‘*’ sign between any two numbers.
Note: Add sign between two numbers on the basis of numbers not on the value calculated till that number.
For eg: n = 5120    
(((5  + 1 )  + 2 )  + 0 ) = 8 is right.
5120   
(((5  + 1 )  * 2 )  + 0 ) =  12 is wrong.
Input:
First line of input contains number of testcases.
Each testcase has a line of input contains a string.

Output:
Print the maximum value obtained from the string.Value can be very large,so print using modulo 10^9+7.

How to sort in descending order using STL programming ?

To sort an array in increasing order simply write sort(a,a+n).
for sorting in decreasing order use sort(arr, arr+n, greater<int>());

where a is name of array a[] and n is size of array ;

Form largest number from digits

Given an array of digits form 0 to 9 of size n, the task is to rearrange elements of the array such that after combining all the elements of the array number formed is maximum.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The f
irst line of each test case contains an integer n denoting the number of elements in the array. Then in the next line are n space seperated integers denoting the elements of the array.

Output:
For each test case print a single line a number denoting the largest number that can be achieved by rearranging the elements of the array.

Internship on Data Analytics with Managerial Applications

Internship in
Data Analytics with Managerial Applications
IIM Lucknow


I am offering an internship in Data Science and Analytics with Managerial Applications. This document has detailed information about the internship and instructions on how to apply.



  • This is a remote internship. This means that if you are selected, you will do your assigned work, long-distance, as per your own convenience. You will interact with me by means of email, phone and/or other digital media.
  • There are no fees. There is no stipend. You do need purchase some teaching materials prescribed by me, in original -  some Cases sold by Harvard Business Publishing and some videos on Data Science and Analytics using R programming.
  • If you successfully complete this internship, you will receive a certificate from me.

Triplet Sum in Array

Given an array A[] of n numbers and another number x, determine whether or not there exist three elements in A[] whose sum is exactly x.
Expected time complexity is O(n^2).
Input:
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is n and x, n is the size of array.
The second line of each test case contains n integers representing array elements C[i].

Output:
Print 1 if there exist three elements in A whose sum is exactly x, else 0.

Find Count Digit


Given a positive integer N. Write a program to find count of digits of the number which evenly divides the number N.
Input:
First line of input of contains a single integer T which denotes the number of test cases. T test cases follows. First line of each test cases contains a single integer N.

Output:
For each test case print the count of all those digits in N which evenly divides N.


Naive Pattern Searching using C++

This algorithm is used to search location of pattern in a string .
Example :
Input
string : My name is Bijendra kumar
pattern : Bijendra

Output
pattern is found at i=11;

Count type of Characters

Given a string S, write a program to count the occurrence of Lowercase characters, Uppercase characters, Special characters and Numeric values in the string.
Input:
First line of input contains a single integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains a string S.
Output:
For each test case, print four lines. In the first line print the count of upper case letters, in the second line print the count of lower case letters, in the third line print the count of numbers and in the fourth line print the count of special characters present in the string S.

Number of occurrence

Given a sorted array C[] and a number X, write a function that counts the occurrences of X in C[].
Input:
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N and X, N is the size of array.
The second line of each test case contains N input C[i].

Output:
Print the counts the occurrence of X, if zero then print -1.

Minimum difference pair

Given an unsorted array, find the minimum difference between any pair in given array.
Input:
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N, the size of array. Second line of the test case is the Array.

Output:
Print the minimum difference between any two pairs.

Pairs of prime number

Print all pairs(sets) of prime numbers (p,q) such that p*q <= n, where n is given number.
Input:
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is N.

Output:
Print the all pairs of prime numbers in increasing order and in single line.
Example:
15 :- 2 2 2 3 2 5 2 7 3 2 3 3 3 5 5 2 5 3 7 2
42 :-  2 2 2 3 2 5 2 7 2 11 2 13 2 17 2 19 3 2 3 3 3 5 3 7 3 11 3 13 5 2 5 3 5 5 5 7 7 2 7 3 7 5 11 2 11 3 13 2 13 3 17 2 19 2

Leaders in an array

Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. The rightmost element is always a leader. 
Input:
The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the size of array.
The second line contains N space-separated integers A1, A2, ..., AN denoting the elements of the array.
Output:
Print all the leaders.

Sum of Digits Divisibility Show Topic Tags

Check that the number can be divided by the sum of its digit.
Input:
The first line of input contains an integer T denoting the number of test cases.Then T test cases follow .Each test case consist of an integer N.
Output:
Print 1 if divisible else 0.

Generate Binary Numbers

Sum of primes

Your task is to calculate sum  of primes present as digits of given number N.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The next T lines contains an integer N.

Output:
Print sum of primes in the digit

Angle between hour and minute hand

Calculate the angle between hour hand and minute hand.
There can be two angles between hands, we need to print minimum of two. Also, we need to print floor of final result angle. For example, if the final angle is 10.61, we need to print 10.

Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of one line conatining two space separated numbers h and m where h is hour and m is minute.
Output:
Coresponding to each test case, print the angle b/w hour and min hand in a separate line.

Minimize the sum of product

Given two arrays, A and B, of equal size n, the task is to find the minimum value  of A[0] * B[0] + A[1] * B[1] +…+ A[n-1] * B[n-1], where shuffling of elements of arrays A and B is allowed.

Examples:

Input : A[] = {3, 1, 1} and B[] = {6, 5, 4}.
Output : 23 Minimum value of S = 1*6 + 1*5 + 3*4 = 23.

Input : A[] = { 6, 1, 9, 5, 4 } and B[] = { 3, 4, 8, 2, 4 }
Output : 80. Minimum value of S = 1*8 + 4*4 + 5*4 + 6*3 + 9*2 = 80.

Input:
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains three lines. The first line of input contains an integer N denoting the size of the arrays. In the second line are N space separated values of the array A[], and in the last line are N space separated values of the array B[].

Output:
For each test case in a new line print the required result.

Constraints:
1<=T<=100
1<=N<=50
1<=A[]<=20

Example:
Input:

2

3 1 1
6 5 4
5
6 1 9 5 4
3 4 8 2 4
Output:
23 
80
Your Code
#include<iostream>

using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int i,j;
int a[100],b[100];
int n;
cin>>n;
for(i=0; i<n; i++)
{
cin>>a[i];
}
for(i=0; i<n; i++)
{
cin>>b[i];
}
for(i=0; i<n-1; i++)
{    int c=i;
    int d=i;
for(j=i+1; j<n; j++)
{
if(a[c]>=a[j])
{
c=j;
}
if(b[d]>=b[j])
d=j;
}
}
if(c!=i)
{
int temp=a[i];
a[i]=a[c];
a[c]=temp;
}
if(d!=i)
{
int temp1=b[i];
b[i]=b[d];
b[d]=temp1;
}

}
/* for(i=0; i<n; i++)
{
// cout<<a[i]<<" ";
           cout<<b[i]<<" ";
}*/
int sum=0;
for(i=0;i<n; i++)
{
sum=sum+a[i]*b[n-1-i];
//cout<<a[i]*b[n-1-i]<<endl;
}
cout<<sum<<endl; 
}
}

Follow us

Follow Bijendra Kumar on Facebook