I have a very large integer value such as 2874. I wrote a function that can return me a list containing all possible outcomes if I start placing commas between this large integer value. How can i reduce the complexity of this function






#zero commas

Jump Search is a searching algorithm for sorted arrays. The basic idea is to check fewer elements (than linear search) by jumping ahead by fixed steps or skipping some elements in place of searching all elements.
For example, suppose we have an array arr[] of size n and block (to be…

Search a sorted or non-sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise, narrow it…

Given a Binary Tree, print Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side. The task is to complete the function leftView(), which accepts root of the tree as argument.

Left view of following tree is 1…

Given an array of integers of size N find subarray with maximum xor. A subbarray is a contiguous part of array.

Example 1:

N = 4
arr[] = {1,2,3,4}
Output: 7
The subarray {3,4} has maximum xor
value equal to 7.

Your Task:
You don’t need to read…

Given two distinct words startWord and targetWord, and a list denoting wordList of unique words of equal lengths. Find the length of the shortest transformation sequence from startWord to targetWord.
Keep the following conditions in mind:

  • A word can only consist of lowercase characters.
  • Only one letter can be changed…

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly numbers. By convention, 1 is included. Write a program to find Nth Ugly Number.

Example 1:

N =…

Sairam Penjarla

Looking for my next opportunity to make change in a BIG way

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store