Embercode
✕
Dynamic ProgrammingQuick quiz

Digit DP

7 questions. Covers Digit DP: counting numbers with a property.

Questions 1 to 5 of 7

  1. 1. In DigitCounter, the prev argument is set to 10 while started is false. What does 10 mean there?
  2. 2. Why does go write its answer to memo_ only when tight is false?
  3. 3. What does this program print? ``cpp #include <iostream> #include <string> bool ok(int x) { std::string s = std::to_string(x); for (std::size_t i = 1; i < s.size(); ++i) if (s[i] == s[i - 1]) return false; return true; } int main() { int count = 0; for (int x = 1; x <= 30; ++x) count += ok(x); std::cout << count << '\n'; } ``
  4. 4. What does this program print? ``cpp #include <iostream> int main() { int count = 0; for (int x = 0; x <= 100; ++x) { int sum = x / 10 + x % 10; if (sum == 7) ++count; } std::cout << count << '\n'; } ``
  5. 5. DigitCounter is built for a 19-digit N. How many slots does its memo_ vector hold?

    Type a number.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.