Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3676436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:05:56+00:00 2026-05-19T03:05:56+00:00

a grid of NxN is given. each point is assigned a value say num

  • 0

a grid of NxN is given. each point is assigned a value say num

starting from 1,1 we have to traverse to N,N.

if i,j is current position we can go right or down.
How to find the min sum of digits by traversing from 1,1 to n,n along any path
any two points can have same number
ex

1 2 3

4 5 6

7 8 9

1+2+3+6+9 = 21
n <=10000000000

Output 21
Can someone explain how to approach the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:05:56+00:00Added an answer on May 19, 2026 at 3:05 am

    This is a dynamic programming problem. The subproblem here is the minimum cost/path to get to any given square. Because you can only move down and to the right, there are only two squares that can let you enter a given square, the one above and the one to the left. Therefore the cost of getting to a square (i,i) is min(cost[i-1][i], cost[i][i-1]) + num. If this would put you out of bounds, only consider the option that is inside the grid. Calculate each row from left to right, doing the top row first and working your way down. The cost you get at (N,N) will be the minimal cost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a grid of nxn squares, where each square has an id, the first(top
Lets say you have a GridLayout of JButtons in an NxN grid, in code
Suppose you have an NxN grid, and you want to visit every cell exactly
I have a grid of 30 buttons, and I want to have it from
I have a NxN grid of values and a 2xM list of x,y data
I currently have a grid made out of square DIVs (200px x 200px each).
I have an array of size n^2 representing a square grid of size nxn.
I have a grid of NxN cells (think of a 2 dimensional array defined
I have a NxN grid with some values, which change every time step. I
I have a grid of divs, and each has content in it: some text,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.