Phone screen for Goldman java developer

I have a call setup with coderpad ..what questions can I expect?

Bank of America i < n Oct 29, 2019

My language of choice java 1. Reverse a string - then asked diff between string and stringbuilder 2. Inputs: i. list of strings, ii. another string (testStr) Return a list of unique words from the given list that can be formed by the chars in testStr.

Intel LvOT55 Oct 29, 2019

Someone asked me to sort a linked list

New
Incept Oct 30, 2019

This is my exact question with solution from a month ago, I copied it to the clipboard: /* Problem Name is &&& Lowest Price &&& PLEASE DO NOT REMOVE THIS LINE. */ /* Instructions to candidate. 1) Run this code in the REPL to observe its behaviour. The execution entry point is main. 2) Consider adding some additional tests in doTestsPass(). 3) Implement getLowestPrices() correctly. 4) If time permits, some possible follow-ups. Question: A popular online retailer allows vendors to specify different prices in advance for the same item throughout the day. We now need to design an algorithm that helps identify the lowest price for the item at any point of the day. Assumptions: 1) For the algorithm, assume all vendors are selling the same product and there is only one product being sold. Given a list that has vendor information - ( startTime, endTime, price ) of the deal, return a sorted list with different possible intervals and the least price of the product during the interval. 2) The interval is inclusive of start and end time. 3) All the 3 values passed by the vendor are integers. */ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; public class Solution { private class Interval { int startTime; int endTime; int price; Interval( int startTime, int endTime, int price ) { this.startTime = startTime; this.endTime = endTime; this.price = price; } } private List<Interval> getLowestPrices( List<Interval> vendors ) { HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>(); List<Interval> out = new ArrayList<Interval>(); for(int i = 1; i <= 24; i++) hm.put(i,-1); for(Interval i : vendors) { for(int j = i.startTime; j <= i.endTime; j++) { if(hm.get(j) < 0 || hm.get(j) > i.price) { hm.put(j, i.price); } } } for(int i = 1; i <= 24; i++) System.out.println(hm.get(i)); int c = 2; while(c <= 24) { int s = c-1; int curr = hm.get(c); while(c <= 24 && curr == hm.get(c)) { c++; } if(curr != -1) out.add(new Interval(s, c-1, curr)); c++; } for(Interval i : out) System.out.println(i.startTime +"-"+ i.endTime +"-"+i.price); return out; } /** * Returns true if the tests pass. Otherwise, false. */ /* 1 20 2 20 3 20, 15 4 20, 15 5 20, 15 6 15 7 15 , 8 8 15, 8 9 8 10 8 */ private boolean doTestsPass() { Interval[] sampleInput = { new Interval( 1, 5, 20 ), new Interval( 3, 8, 15 ), new Interval( 7, 10, 8 ) }; Interval[] expectedOutput = { new Interval( 1, 2, 20 ), new Interval( 3, 6, 15 ), new Interval( 7, 10, 8 ) }; List<Interval> inputList = new ArrayList<>( Arrays.asList( sampleInput ) ); List<Interval> expectedList = new ArrayList<>( Arrays.asList( expectedOutput ) ); return expectedList.equals( getLowestPrices( inputList ) ); } /** * Execution entry point. */ public static void main( String[] args ) { Solution solution = new Solution( ); if ( solution.doTestsPass( ) ) { System.out.println( "All tests passed" ); } else { System.out.println( "Tests failed" ); } } }

HSBC tdfjb Aug 18, 2021

Parsing apache logs to find the count of IP address. They expect you to write entire code & execute it on coderpad.