Nitin
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
We can use a custom object to store such type of data as depicted below.
class NestedArray{
private Object[] e;
NestedArray(Object e){
if(e instanceof Integer) {
this.e = new Integer[] {(Integer)e};
}else if(e.getClass().isArray()) {
this.e = (Object[]) e;
}
}
void printArray(Object[] e) {
for(Object o: e) {
if(o instanceof Integer) {
System.out.println((Integer)o);
}else if(o.getClass().isArray()) {
printArray((Object[]) o);
}
}
}
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
We can think of weighted graph and finding shortest distance between 2 nodes.
- Nitin December 26, 2017Eg:
EUR---(1.2)---> USD ---(0.75)--->GBP---(1.7)--->AUD
| |(90)
|___(150)--->JPY-----(0.60)------>INR