## Goldman Sachs Interview Question for Software Engineer / Developers

• 1
of 1 vote

Country: Singapore
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
1
of 1 vote

My idea is -
1. Convert the input to uni-cost graph
2. Find shortest path between two input odes and keep track of the conversation rate of the edges that are part of the shortest path.
3. Multiply the the rates with given amount

Comment hidden because of low score. Click to expand.
0
of 0 vote

We can think of weighted graph and finding shortest distance between 2 nodes.
Eg:
EUR---(1.2)---> USD ---(0.75)--->GBP---(1.7)--->AUD
| |(90)
|___(150)--->JPY-----(0.60)------>INR

Comment hidden because of low score. Click to expand.
0
of 0 vote

It should be unicost graph, in my opinion, since the task is to minimize the number of intermediate conversions.

Comment hidden because of low score. Click to expand.
0
of 0 vote

Just use dijsktra.

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class CurrencyConvert {

public static int getMinimum(ArrayList<Integer> unVisited,float []weight){
float minimum = Float.MAX_VALUE;
int position =-1;
for(int i:unVisited){
if(weight[i]<minimum){
minimum=weight[i];
position =i;
}
}
return position;
}

public static float myFunction(HashMap<String,Integer> myHashMap,float[][] adMatrix,String source,String destination,int amount){
ArrayList<Integer> unVisted = new ArrayList<Integer>();
for(int i=0;i<myHashMap.size();i++){
}
ArrayList<Integer> visited = new ArrayList<Integer>();
float weight[] = new float[myHashMap.size()];
int sourceIndex= myHashMap.get(source);
for(int i=0;i<weight.length;i++){
weight[i]=Integer.MAX_VALUE;
}
weight[sourceIndex]=1;
while(!unVisted.isEmpty()){
int minimumIndex = getMinimum(unVisted,weight);
}
}
int index = unVisted.indexOf(minimumIndex);
unVisted.remove(index);
}
for(int i=0;i<weight.length;i++){
System.out.println(weight[i]);
}
return weight[myHashMap.get(destination)]*amount;
}

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String nodes ="EUR,USD,GBP,AUD,JPY,INR";
String [] newlength = nodes.split(",");
float [][] adMatrix = new float[newlength.length][newlength.length];
HashMap<String,Integer> myHashMap= new HashMap<>();
for(int i=0;i<newlength.length;i++){
myHashMap.put(newlength[i],i);
}
List<String> graph = new ArrayList<>();
String a = "EUR/USD=1.2";
String b = "USD/GBP=0.75";
String c = "GBP/AUD=1.7";
String d = "AUD/JPY=90";
String e = "GBP/JPY=150";
String f = "JPY/INR=0.6";
for(int i=0;i<graph.size();i++){
String line = graph.get(i);
String[] equaldivide = line.split("=");
String[] curr = equaldivide[0].split("/");
}
String source ="EUR";
String destination ="INR";
}
}``````

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.