title: Check Whether Given Degrees Vertices Represent Graph Tree
signature: def checkWhetherGivenDegreesVerticesRepresentGraphTree(degree: List[Int], n: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Boolean , expected: Boolean): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(degree: List[Int], n: Int, expected: Boolean): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(degree, n),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        List(2, 3, 1, 1, 1), 5, 
        true    
      )}")   
  
  
      println(s"TEST-1...${driver(
        List(2, 2, 1, 1, 2), 5, 
        true    
      )}")   
  
  
      println(s"TEST-2...${driver(
        List(2, 2, 1, 1, 1), 5, 
        false    
      )}")   
  
  
      println(s"TEST-3...${driver(
        List(0, 0, 0, 3, 3, 4), 6, 
        true    
      )}")   
  
  
      println(s"TEST-4...${driver(
        List(-10, 12, 2), 3, 
        true    
      )}")   
  
  
      println(s"TEST-5...${driver(
        List(1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0), 19, 
        false    
      )}")   
  
  
      println(s"TEST-6...${driver(
        List(1, 6, 10, 13, 15, 17, 18, 23, 26, 28, 30, 32, 32, 33, 36, 39, 39, 41, 43, 50, 50, 51, 53, 54, 59, 59, 63, 63, 63, 66, 66, 71, 71, 74, 78, 89, 89, 93), 30, 
        false    
      )}")   
  
  
      println(s"TEST-7...${driver(
        List(66, -96, -14, 74, -20), 4, 
        false    
      )}")   
  
  
      println(s"TEST-8...${driver(
        List(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 31, 
        false    
      )}")   
  
  
      println(s"TEST-9...${driver(
        List(97, 73, 87, 45, 64, 30, 53, 50, 62, 42, 28, 58, 31, 90), 10, 
        false    
      )}")   
  
  }
  
source_py: def check_whether_given_degrees_vertices_represent_graph_tree(degree, n):
      deg_sum = sum(degree)
      if ((2 * (n - 1)) == deg_sum):
          return True
      else:
          return False
source_cpp: bool check_whether_given_degrees_vertices_represent_graph_tree(vector<int> degree, int n) {
    int deg_sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) deg_sum += degree [ i ];
    return ( 2 * ( n - 1 ) == deg_sum );
  }