₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,158 members, 8,510,452 topics. Date: Friday, 30 October 2026 at 12:18 PM

Toggle theme

Javascript Function To Java - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Javascript Function To Java (832 Views)

1 Reply (Go Down)

Javascript Function To Java by islamics(op): 3:29pm On Dec 31, 2021
Hello,
I am following a YouTube video on dynamic programming. So the guy solve a problem on number of route available in a given grid that requires you to go right or down. He did the solution in JavaScript, I am having problem to replicate it in Java.
This is the JavaScript function:

const gridtravel = (m, n, memo = {} => {
const key = m + ',' + n;
if (key in memo) return memo[key];
if(m === 1 && n === 1) return 1;
if(m === 0 || n === 0) return 0;
memo[key] = gridtravel(m - 1, n, memo) + gridtravel(m, n - 1, memo);
return memo[key];
}


This is my trial in Java;

public static int gridTravel (m, n){
Map<String, Integer> memo = new Map<>();
String key = m + ',' + n;
if (memo.contains(key)) return memo.get(key);
if(m == 1 && n == 1) return 1;
if(m == 0 || n == 0) return 0;
memo.put(key, gridtravel(m - 1, n) + gridtravel(m, n - 1));
return memo.get(key);
}


I don't know how to replicate with the memo object use in JavaScript. The function is suppose to have two parameter of row and column.
This approach is trying to get an optimized solution
Cc
qtguru et al grin
Re: Javascript Function To Java by islamics(op): 11:14pm On Dec 31, 2021
Omo! No show here.
I have gotten a way around it sha. If only JS was strongly typed language, I would have known the types used.
Re: Javascript Function To Java by islamics(op): 11:18am On Sep 19, 2023
@ airsaylongcome Trust you are doing good.
Abeg na open source recommendation I want for Staff Invigilation scheduling (with regard to exams or so) and creating a journal management site.
For the journal management, I stumbled upon Open Journal System (OJS) and luckily, they have a youtube channel which I am already going through but no luck with that of the invigilation.

Thanks in anticipation of your response.
Re: Javascript Function To Java by airsaylongcome: 12:30pm On Sep 19, 2023
islamics:
@ airsaylongcome Trust you are doing good.
Abeg na open source recommendation I want for Staff Invigilation scheduling (with regard to exams or so) and creating a journal management site.
For the journal management, I stumbled upon Open Journal System (OJS) and luckily, they have a youtube channel which I am already going through but no luck with that of the invigilation.

Thanks in anticipation of your response.
www dot abc-roster dot com
This isn't open source but I've used it in a rush

www dot optaplanner dot org
Open source but has a learning curve

Also
github dot com/LandRover/StaffjoyV2
Re: Javascript Function To Java by islamics(op): 8:21pm On Sep 19, 2023
airsaylongcome:
www dot abc-roster dot com
This isn't open source but I've used it in a rush

www dot optaplanner dot org
Open source but has a learning curve

Also
github dot com/LandRover/StaffjoyV2
Thanks very much Sir; this is well appreciated.
Re: Javascript Function To Java by islamics(op): 10:26pm On Aug 05
@ airsaylongcome
Good Evening Sir, Trust you are doing good.

I don come again 🙏
Abeg na open source recommendation I want for asset management system for an organization.

My search yielded snipe-it and GLPI; I don't know if your suggestions might be better.

Thanks in anticipation of your response
Re: Javascript Function To Java by airsaylongcome: 11:20am On Aug 06
islamics:
@ airsaylongcome
Good Evening Sir, Trust you are doing good.

I don come again 🙏
Abeg na open source recommendation I want for asset management system for an organization.

My search yielded snipe-it and GLPI; I don't know if your suggestions might be better.

Thanks in anticipation of your response
Anything outside those two is a huge waste of time. I prefer Snipe-IT over GLPI purely because I stumbled on Snipe first. But I not dey waste time on anything outside those. If na Facility Management business trying to keep inventory and maintenance trail for various building related assets , I use openMAINT
Re: Javascript Function To Java by islamics(op): 3:20pm On Aug 06
airsaylongcome:
Anything outside those two is a huge waste of time. I prefer Snipe-IT over GLPI purely because I stumbled on Snipe first. But I not dey waste time on anything outside those. If na Facility Management business trying to keep inventory and maintenance trail for various building related assets , I use openMAINT
Thanks very much Sir 🙏. I will look into the openMAINT too.
1 Reply

I Want To Java • Mobile Technology: Lets Build A Mobile App With Javascript • Introduction To Java • 2 • 3 • 4

. • Needing Help • What Is Programming