Tag Archives: large-numbers

Multiply Large Numbers represented as Strings

Given two numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find sum of these two numbers. Examples: Input : num1 = 4154 num2 = 51454 Output : 213779916 Input : num1 = 654154154151454545415415454 num2 = 63516561563156316545145146514654 Output : 41549622603955309777243716069997997007620439937711509062916 The idea is based… Read More »

Sort an array of large numbers

Given an array of numbers where every number is represented as string. The numbers may be very large (may not fit in long long int), the task is to sort these numbers. Examples: Input : arr[] = {“5”, “1237637463746732323”, “12” }; Output : arr[] = {“5”, “12”, “1237637463746732323”}; Input : arr[] = {“50”, “12”, “12”,… Read More »

Difference of two large numbers

Given two numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find difference of these two numbers. Examples: Input : str1 = “11443333311111111100”, str2 = “1144422222221111” Output : 11442188888888889989 Input :str1 = “122387876566565674”, str2 = “31435454654554” Output : 122356441111911120 This is simple based on… Read More »

Sum of two large numbers

Given two numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find sum of these two numbers. Examples: Input : str1 = “3333311111111111”, str2 = “44422222221111” Output : 3377733333332222 Input : str1 = “7777555511111111”, str2 = “3332222221111” Output : 7780887733332222 The idea is based… Read More »