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

  • SEARCH
  • Home
  • 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 7074213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:01:31+00:00 2026-05-28T06:01:31+00:00

I am working to solve a problem that is a bit similar to Euler

  • 0

I am working to solve a problem that is a bit similar to Euler Problem 215. I think I can explain this without explaining the entire problem and/or my full approach to solving it.

Right now I’m making recursive calls with RT([Arraylist of numbers], int i). As per the technique, I want to save the results, so if and when RT asks for the same problem, I can simple just look up the answer instead of recurring until the base case is reached.

Just to illustrate RT([3, 7.5, 10.5, 15], 2). In the recursion, the right in the right side to increment. The Arraylist is used to identify what else it needs to recall to the base case.

Usaully, my understanding of Dynamic Programming usually uses 2D Arrays where the results are saved and stored using what’s being called as the reference point. This is great if it is something like RT(int x, int y). But what about my problem?

I guess I can change the ArrayList to a string 37510515 and then to some used ASCII numbers or perhaps the numbers itself. But I’m hoping I can approach this like a HashMap where I use the ArrayList as a key, but the flaw in this a HashMap only works well with one value (I know I can chain, but how would that work in storing results while easily keeping track of what “int i” it is called on?)

So in short, can anyone help me think of a way to store results with an ArrayList and an int as the two references?

Thanks in advance!

  • 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-28T06:01:32+00:00Added an answer on May 28, 2026 at 6:01 am

    You can use objects of any class you like as keys for a HashMap, and it will work if the object has defined equals() and hashCode() properly. These methods have already been implemented properly in ArrayList, so you should find that using ArrayLists as HashMap keys works perfectly well.

    If you want to use an ArrayList and a number combined as a key for a HashMap, you could either define a class for this, implementing hashCode() and equals() in that class, or cheat a bit by making the number just the last entry in the arraylist.

    It sounds like what you are doing is more like http://en.wikipedia.org/wiki/Memoization than dynamic programming, but it may get the job done – I guess that the Euler problem has been set to make it doable for the best technique – if that is memoization or dynamic programming you should find it is affordable. It that takes too long, then both of us have missed some more efficient method.

    One way of speeding it up further would be to take advantage of symmetries in the problem – e.g. if your state corresponds to a row (or a column) of blocks, then that is essential the same state as the row with the same blocks laid out right to left instead of left to right, or bottom to top instead of top to bottom.

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

Sidebar

Related Questions

If anyone can get this guy's small bit of code working on their machine,
I'm still working on my leaks problem and I don't know how to solve
I'm working on a spatial stacking problem... at the moment I'm trying to solve
EDIT : For anyone who might come across this post with a similar problem,
In order to solve the Euler Project problem n°5 , I wrote the following
I have an interesting problem that I'm trying to solve and was wondering if
Problem solved, see below Question I'm working in Flex Builder 3 and I have
I've been working with PHP lately, and I came across something I couldn't solve.
Working with a SqlCommand in C# I've created a query that contains a IN
I'm pretty sure that due to the Application Sandbox, none of this is possible,

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.