Goldman Sachs | Coderpad | Longest Substring & ATOI
Anonymous User
1752

Intoduction:
Coderpad is the second round that GC conducts after the Hackerrank online assesment

For Role - Associate
Experience - 3.5 Years
Duration - 1 hr

Question 1: Largest Substring (Easy)
Given a string s, find the longest subtring of str and return an array of length 2, such that the 0th index must contain the starting index of the largest substring and the 1st index must contain the length of the largest substring.

Constraints:
0 <= str.length <= 10000
s can contain any character

Example:
Input: str = "aaBBccccc"
Output: {4, 5}
Explanation: ccccc is the largest substring in str with starting index of 4 and length of 5.

Input: str = "122201111133"
Output: {5, 5}

Question 2: Implement AOTI (Medium)
Implemnet a function named aoti which can convert a string based integer number to an integer.

Constraints:
1 <= str.length <= 11
str can contain a negative string
str can contain alphanumeric character

Example:
Input: str = "123"
Output: 123

Input: str = "0010"
Output: 10

Innput str = "-00500"
Output: -500

Input str = "-Rw1100"
Output: 0

Bonus:

  1. The interviwer asked to think of more test cases run the program for them.
  2. Was asked to optimize the appoach.

I was able to solve and optimize the approah for both.

Thanks!

Comments (2)