Thursday, April 12, 2018

UVa problem solution 10931 - Parity

problem link:


Discuss: in this problem you just simply convert decimal to binary. then count the number of one's in binary that will be the 'P'. and for converting you can use c++ built in STL     string binary = std::bitset<31>(n).to_string();   . and there is no tricky part in this problem.

try yourself, before see the code



Friday, April 6, 2018

UVa problem solution 514 - Rails

problem link:

Discuss: in this problem train come from direction A in increasing order and there can many permutation to go direction B. input gives you the permutation to go direction.you can easily check it by using stack.just if top element of stack is less then ith element then push more. if ith element is in stack but not in top then the permutation is impossible



Thursday, April 5, 2018

UVa problem 673 - Parentheses Balance

problem link:

Discuss: This problem i want to solve by counting parentheses before  i know stack. since i know i just laugh at myself. if you know stack then it is just implementation problem for you.there no tricky part in this problem

try yourself before see the code


UVa problem solution 727 - Equation

problem link:

Discuss: in this problem you may first trouble with taking input.it's quite okay it's a terrific one before but it's not like that. you can take input as string and if the first character of string is null character just break the loop.and obviously give a null end of your main string. and other simply need to convert it infix to post fix. if you know stack then it just  a implementation problem for you.

try your self, before see the code