Google | Data structure to manipulate a very long string
20157
Oct 26, 2019
Mar 19, 2020

Design a tree-based data structure to efficiently manipulate a very long string.

class LongString {

	public LongString(String s) {
		// todo
	}
	
	/**
	* Returns the character at position 'i'.
	*/
	public char charAt(int i) {
		// todo
	}

	/**
	* Deletes the specified character substring.
	* The substring begins at the specified 'start' and extends to the character at index 'end - 1' or to the end of the sequence
	* if no such character exists.
	* If 'start' is equal to 'end', no changes are made.
	*
	* @param      start  The beginning index, inclusive.
	* @param      end    The ending index, exclusive.
	* @throws     StringIndexOutOfBoundsException  if 'start' is negative, greater than length, or greater than 'end'.
	*/
	public void delete(int start, int end) {
		// todo
	}
}
Comments (21)