Ragesh
BAN USER- 0of 0 votes
AnswersTime Complexity ?
- Ragesh in United States for Seattle
a. Inserting a node in Linked List?
b. HashMap time complexity?| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 0of 0 votes
AnswersFind missing number from sequence of numbers in an array? Time Complexity?
- Ragesh in United States for Seattle| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 0of 0 votes
AnswerTime Complexity ?
- Ragesh in United States for Seattle
a. Inserting a node in Linked List?
b. HashMap time complexity?| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersFind missing number from sequence of numbers in an array? Time Complexity?
- Ragesh in United States for Seattle| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersReverse a String using Recursion and unit tests?
- Ragesh in United States for Seattle| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersHow to calculate sum of all numbers in a string. Example 11aa22bb33dd44 =110
- rageshpayyan in United States for Seattle
Note: Should not use Regex and replace| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("Enter the string");
string str = Console.ReadLine();
str = str + " ";
int sum=0;
string strSum=string.Empty;
for(int i=0;i<str.Length;i++)
{
if((str[i] >='0') && (str[i] <= '9'))
{
strSum = strSum + str[i];
}
else
{
if(strSum.Length>0)
{
sum = sum + Convert.ToInt32(strSum);
strSum=string.Empty;
}
}
}
Console.WriteLine("sum: " + sum);
}
}
RepAriasBitner, Systems developer at 247quickbookshelp
I am a Systems developer . My duties primarily revolve around building software by writing code, as well as modifying software ...
what is the time complexity? How will you sum all the numbers from an array using loop?,if yes then time complexity will be O(n). Is there any better solution?
- Ragesh September 02, 2016