One To Three | Starters 161(Rated for all) | START161 | Maths

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ •

  • @codeNLearnNCode
    @codeNLearnNCode  Місяць тому +1

    Problem Link: www.codechef.com/problems/ONETOTHREE

  • @samwilder6199
    @samwilder6199 28 днів тому

    In this can't we just from left to right twice it should be able to give the same answer or am i wrong

    • @codeNLearnNCode
      @codeNLearnNCode  28 днів тому +1

      no that will not help why let's see one example
      2 3 3 3 3 1
      once you iterated from left to right
      2 3 3 3 1 1
      second time you did
      2 3 3 1 1 1
      but still you need to one more time in order to minimize the sum that is why it is better to iterate from right after left iteration as it will get sorted out in one loop (from right)

    • @samwilder6199
      @samwilder6199 28 днів тому

      Got it thanks