Amazon Interview Question

Given input string which represents path (foo/bar/$id), how would you write a function which returns $id?

Interview Answer

Anonymous

May 28, 2018

Split by "/" and return last element or find index of last "/" and then substring everything afterwards. It was a slight challenge to explain how I'd write an actual method over the phone.