On Friday, December 14, 2012 11:56:16 AM UTC+5:30, tapan rathi wrote:
For a given number, find the next greatest number which is just greater
than previous one and made up of same digits.
--
--
--
Regards
Anurag Gupta
IV Year Computer Engineering
Delhi Technological University
.However there is no need to sort.
On Friday, December 14, 2012 11:56:16 AM UTC+5:30, tapan rathi wrote:
For a given number, find the next greatest number which is just greater
than previous one and made up of same digits.
--
--
Regards
Anurag Gupta
IV Year Computer Engineering
Delhi
loop from the end of given number till you get a digit less than the
previously scanned digit.Let the index of that number be 'i' .
if index = -1,then the given number is the largest one
else do the following
1) swap the digit at the index i with the digit just greater than it in the
scanned
The complexity of above code is exponential.
Here is the simple recurrence for the given problem
F(n) = 2*F(n-1) + F(n-2) + F(n-3) for n = 4
where F(1) = 2
F(2) = 5
F(3) = 13
precompute the values and each query will then be O(1)
On Thu, Aug 23, 2012 at 8:22
if we just need to determine number of swaps, it can be Done in O(n)
Ex : 11100010
start counting number of zeros from the end
so we have zeroCount = 1
whenever we encounter a 1 we add current zeroCount to numberOfSwaps
so numberOfSwaps = 1
and so on the final value of numberOsSwaps is the
+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.
--
Regards
Anurag Gupta
III Year Computer Engineering
Delhi Technological University
(Formerly Delhi College of Engineering)
--
You received this message because you are subscribed
I think this works and the complexity is O(sqrt(n))
#includecmath
#includecstdio
#includeiostream
#includecstring
#includecstdlib
using namespace std;
# define INFY 17
int main()
{
int n, i, j;
int val, minDiv, minDis;
while(1)
{
cin n;
minDis =
how can we take mod by a very large number
for example 100283
int mod = 100283;
ans % mod
is not working
Please Help
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
What about this approach:
First we will scan the first array and find the smallest number.
if it is -ve then we increment all numbers in both the arrays by that
number .
This ensures that every integer in first array is = 0
some integers in 2nd one maybe -ve if it is,then two arrays are
not
SuperSum is a function defined as:
* SuperSum(0 , n) = n, for all positive n.
* SuperSum(k , n) = SuperSum(k-1 , 1) + SuperSum(k-1 , 2) + ... +
SuperSum(k-1 , n), for all positive k, n.
Given k and n, return the value for SuperSum(k , n) modulo 17.
1=k=50
1=n=1,000,000,000
For Example:
that means the range of input is 1 to n^3
i.e there are n numbers and the numbers can vary from 1 to n^3
On Nov 14, 3:48 pm, Carl Barton odysseus.ulys...@gmail.com wrote:
Bit confused by your n^3.
Could you clarify?
In the mean time Radix is an O(n) sorting algorithm. Where n is the
length
read this
http://www.geeksforgeeks.org/archives/14873
On Nov 8, 10:29 am, Arun Vishwanathan aaron.nar...@gmail.com wrote:
Hi to find running median from a stream of random generated numbers I have
heard of the 2 heap ( min and max heap ) solution but I fail to understand
it...could someone
@ kunal
I was attempting this problem: http://www.spoj.pl/problems/NHAY/
here,input size of haystick is not limited so,can you tell me how to
read the
haystick.
On Sep 7, 12:06 am, Kunal Patil kp101...@gmail.com wrote:
If I understand question correctly, then just read as many characters as
how to read a string whose length is not known
and string is so long that we can't read it all at once?
input (i.e string) is terminated by EOF
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@ Mehnaaz :the variable no_p will be equal to 0,since it is an
external one
so the declaration char p[no_p][max] is equivalent to p[0][max];
and size of p is zero.
then how you can insert anything into it
as you are doing in for loop?
no_p may receive some non zero value afterwards but array p is
you refer cormen too
On Jul 29, 11:19 am, jagrati verma jagrativermamn...@gmail.com
wrote:
an array containing +ve and -ve integers.find sub array with the largest
sum
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
Please suggest any good book for Java (for beginners)
Thanks in advance :)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Maid was the criminal because she lied.
The day was sunday and you don't get mails on sunday
On Apr 29, 12:57 pm, Lavesh Rawat lavesh.ra...@gmail.com wrote:
* RIDDLE OF THE DAY
A man was killed on Sunday morning. His wife found the body and called the
police. The police arrived and
18 matches
Mail list logo