Dynamic programming is a method used in computer science for solving complex problems by breaking them down into simpler subproblems. It involves solving each subproblem only once and storing its solution in a table, thereby avoiding the computation of the same subproblem multiple times. This technique is particularly useful for optimization problems where the solution can be constructed from solutions of its subproblems.