3. Pattern Printing

1. not come in interviews

2. just for practice of loops

3. observe symmetry- if present then write and combine the 2 codes

4. outer loop for row and inner for col entries in a row

5. we just have to somehow connect col to rows.

-----------------------------------------------------------------------------------------------------------------------------                                                                            Pattern 22-

subtract n from each element of matrix

each new element is minimum distance of that position from every side

top dist = i

left dist = j

right dist = (2n-2)-j

bottom dist = (2n-2)-i

after writing all these again subtract final answer from n to get required answer.

-------------------------------------------------------------------------------------------------------------------------

a=min(b,c)

---------------

Comments

Popular posts from this blog

30.) DP on subsequences

19. Strings (LB)

32. Binary Trees-2 (bfs/dfs med problems)