Is Recursion Efficient? Calling a method involves certain overhead. Control must be transferred from the location of the call to the beginning of the method. In addition, the arguments to the method and the address to which the method should return must be pushed onto an internal stack so that Read more…

Compress String Code

Compress a string consisting of only english alphabets, such that the compressed string contains the letter and a number next to it representing the number of times it is repeated. Ignore the number count if letter occurs only once. EXAMPLE: Input: abbcccddddd Output: ab2c3d4 Time Complexity: O(n) Space Complexity: O(n)