Posts

Arithmetic Triangle

Image
Arithmetic Triangle Difficulty: Easy Given an integer  numRows , return the first numRows of Arithmetic 's triangle . In  Arithmetic's triangle , each number is the sum of the two numbers directly above it as shown: Solution:  Java class   Solution   {      List < List < Integer >>   list ;      public   List < List < Integer >>   generate ( int   numRows )   {          list = new   ArrayList <> ();          if ( numRows == 0 )              return   list ;          list . add ( new   ArrayList < Integer >( Arrays . asList ( 1 )));          for ( int   i = 1 ; i < numRows ; i ++){              List < Integer >   l = new   ArrayList < Integer >();              List < Integer >   prev = list . get ( i - 1 );              for ( int   j = 0 ; j <= i ; j ++){                  if ( i == 0 || j == 0 || i == 1 || i == j ){                      l . add ( 1 );                      continue ;                  }                  l

Code Of The Day: Monk and Rotation

Monk and Rotation Monk loves to preform different operations on arrays, and so being the principal of Hackerearth School, he assigned a task to his new student Mishki. Mishki will be provided with an integer array  A  of size  N  and an integer  K  , where she needs to rotate the array in the right direction by K steps and then print the resultant array. As she is new to the school, please help her to complete the task. Input : The first line will consists of one integer  T  denoting the number of test cases. For each test case: 1) The first line consists of two integers  N  and  K ,  N  being the number of elements in the array and  K  denotes the number of steps of rotation. 2) The next line consists of  N  space separated integers , denoting the elements of the array  A . Output : Print the required array. Constraints : 1 ≤ T ≤ 20 1 ≤ N ≤ 10 5 0 ≤ K ≤ 10 6 0 ≤ A [ i ] ≤ 10 6 Sample Input 1 5 2 1 2 3 4 5 Sample Output 4 5 1 2 3 Explanation Here  T  is 1, which means one test case. N

Plot the Given Graph with no Libraries

Image
Print The Given Diagram Using the Given Array No Use Of Libraries The Given Input Is:  b = [10,7,12,2,4,7,2,4,1,2,6,6,3,2,1,4,7,2,7,0,0,0,0,0,0,0,0,0,0,0,3,1,4,2,1,5,2,6,5,3,6,1,1,1] b  =  [ 10 , 7 , 12 , 2 , 4 , 7 , 2 , 4 , 1 , 2 , 6 , 6 , 3 , 2 , 1 , 4 , 7 , 2 , 7 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 1 , 4 , 2 , 1 , 5 , 2 , 6 , 5 , 3 , 6 , 1 , 1 , 1 ] l  =  sum ( b ) d  =  sum ( b [ 0 :: 2 ]) - sum ( b [ 1 :: 2 ]) + len ( b ) // 2 print ( l ) print ( d ) a  =  [[ " "   for   i   in   range ( l )]   for   j   in   range ( d )] x  =  [] for   i   in   range ( len ( b )):      if   i % 2 == 0 :          for   j   in   range (( b [ i ])):              x . append ( 1 )      elif   b [ i ] == 0 :          x . append ( 0 )      else :          for   j   in   range (( b [ i ])):              x . append ( -1 ) print ( x )    g = 0 m = 0 for   i   in   range ( len ( x )):      g += x [ i ]      if   m < g :          m  =  g          ik  =  i print ( "ind

Deep learning Questions To Be Known

Image
Deep Learning Questions and Answers Check out some of the frequently asked deep learning interview questions below: 1. What is Deep Learning? If you are going for a deep learning interview, you definitely know what exactly deep learning is. However, with this question the interviewee expects you to give an in-detail answer, with an example.  Deep Learning  involves taking large volumes of structured or unstructured data and using complex algorithms to train neural networks. It performs complex operations to extract hidden patterns and features (for instance, distinguishing the image of a cat from that of a dog). 2. What is a Neural Network? Neural Networks  replicate the way humans learn, inspired by how the neurons in our brains fire, only much simpler. The most common Neural Networks consist of three network layers: An input layer A hidden layer (this is the most important layer where feature extraction takes place, and adjustments are made to train faster and function better) An out