title: Count Ways Build Street Given Constraints
signature: class Solution {
  
      public Integer countWaysBuildStreetGivenConstraints(Integer n) {
source_py: def count_ways_build_street_given_constraints(n):
      dp = [([0] * (n + 1)) for i in range(2)]
      dp[0][1] = 1
      dp[1][1] = 2
      for i in range(2, (n + 1)):
          dp[0][i] = (dp[0][(i - 1)] + dp[1][(i - 1)])
          dp[1][i] = ((dp[0][(i - 1)] * 2) + dp[1][(i - 1)])
      return (dp[0][n] + dp[1][n])
source_cpp: long count_ways_build_street_given_constraints(int n) {
    long dp [ 2 ] [ n + 1 ];
    dp [ 0 ] [ 1 ] = 1;
    dp [ 1 ] [ 1 ] = 2;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + dp [ 1 ] [ i - 1 ];
      dp [ 1 ] [ i ] = dp [ 0 ] [ i - 1 ] * 2 + dp [ 1 ] [ i - 1 ];
    }
    return dp [ 0 ] [ n ] + dp [ 1 ] [ n ];
  }
question_info.extension: java
question_info.entry_fn_name: countWaysBuildStreetGivenConstraints
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 54608393, "inputs": {"n": 20}}, {"idx": 1, "outputs": 3, "inputs": {"n": 1}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(20, 54608393);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(1, 3);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1
question_info.commands: java __FILENAME__