This weekend, I have participated at the Google Code Jam contest. You only needed to get 30 pts to attend the next round !
For the first question : Because each number always has a the number 4 in it, we can just :
create (initialise) string A and string B
for each digit in the number :
if the digit is a 4 :
put '1' in string B
put '3' in string A
else :
put the digit in string A
For the second question : It is a pretty easy question. The idea is just to replace 'E' by 'S' and 'S' by 'E':
read the string s
for each character c in s :
if c == 'E' :
print 'S'
else :
print 'E'
For the third question : just use Euclid's gcd !
Have a look at the official editorial for question 3 and 4 :
https://codejam.withgoogle.com/2018/challenges/0000000000051705/analysis/000000000008830b
https://codejam.withgoogle.com/2018/challenges/0000000000051705/analysis/00000000000881de
Here is my youtube video (doing A and B) : https://youtu.be/0k4q1SMSYSo
Sunday, 7 April 2019
Subscribe to:
Posts (Atom)
std::next_permutation(arr.begin(),arr.end());
What is next_permutation(a.begin(),a.end()) ? Next permutation is like what its name says, finds the next permutation of a and assigns ...
-
Usage of __int128_t: supports really big intermediate numbers, from -2^128 + 1 to 2^128 - 1 it has 128 bits Usage of __float128 : ...
-
This is one of the not interactive question. (2 out of 4 questions are interactive questions). You can try it ! InfO(1) CUP 2019 Third ...
-
There are many different distances but today we will be talking about Manhattan distance and Euclidean distance. Mahattan distance is based ...