Posts

Showing posts from September, 2021

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 ++){        ...