Hackerrank's Problem Solving solutions( A Very Big Sum, Diagonal Difference, Plus Minus ) :
Problem 4: A Very Big Sum
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
This code is simple. There's no need for any explanation.
Problem 5: Diagonal Difference
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
Let a 3*3 matrix and the position of a given element is represented in the form of (i,j) :
0 1 2
0 (0,0) (0,1) (0,2)
1 (1,0) (1,1) (1,2)
2 (2,0) (2,1) (2,2)
Here we can see for diagonal \ , the elements can be represented by (i,i) but for the diagonal / , the elements can't be represented in a general form. But we can observe that on traversing this diagonal from top right to bottom left i value increases by 1 while j value decreases by 1. This is what i have done in the above code.
Problem 6: Plus Minus
Solution: (in c++)
( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder)
This code is simple. There's no need for any explanation.
Guys , if you have any queries related to a question or need more explanation for a question , comment below!
Comments
Post a Comment