Re: [algogeeks] preprocessor directives

2011-07-26 Thread Naveen Agrawal
I think k value will depend on compiler as we have changed i value in the expression k = ++i*++i and used it again in the same expression. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] How to remove duplicate element from array in one pass.

2011-06-03 Thread Naveen Agrawal
Python implementation using dictionary/hash table # main function def main(): # 'dicti' is a hash table # 's' is string dicti = {}; s = asldhj aldalkd7^Awu3e8 ue8u1o2h3o82708q2 # iterting over the string for i in range(len(s)): # if the character is not in hash table ,then store the character

Re: [algogeeks] How to remove duplicate element from array in one pass.

2011-06-03 Thread Naveen Agrawal
C implementation: #include stdio.h int main() { char arr[100]=ash ;alsdfasf jahfjkjfhsakfjha; int i; int table[256] = {0}; int a; for(i = 0; i=10; i++) { // 'a ' store the ASCII value of arr[i] a = arr[i]; if (table[a] == 0) { table[a] = 1; printf(%c, arr[i]); } } printf(/n); } -- You

Re: [algogeeks] How to remove duplicate element from array in one pass.

2011-06-03 Thread Naveen Agrawal
@Naveen Kumar 1. For Python Implementation I have used string just for example. You can have a list(or array) . Then iterate it through each element of list instead of above implementation(iterating through each character of string) . Rest of the thing will remain same. 2. For C

Re: [algogeeks] Google Interview Question

2011-05-30 Thread Naveen Agrawal
@ shubham Your solution need some changes at step 2 step 1: sort the given numbers in the decreasing order based on their first digit(left most). step 2: if two numbers come out to be equal in the above case both of their next digit exist then sort on the basis of their next

Re: [algogeeks] Re: sort in minimum cost

2011-04-26 Thread Naveen Agrawal
@snehal jain 4 9 8 7 8 o/p 4 7 7 7 8 cost 3 by decrementing 9 n 8 Yes, now question is clear but your last example is incorrect. 4 9 8 7 8 o/p 4 8 8 8 8 cost 2 = decrementing (9 to 8) + incrementing (7 to 8) -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: flux redirction

2011-04-14 Thread Naveen Agrawal
Hi Bounaim, The command for redirecting in Windows are same as available in LINUX. For example: You can redirect the output of the dir command to a file dir file.txt. I you want to know more about the redirection check out this link:

Re: [algogeeks] Fact1 spoj

2010-10-05 Thread Naveen Agrawal
Use array of integers or strings Naveen -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!

2010-09-21 Thread Naveen Agrawal
@Kartheek Ashish algo is perfectly workingBy making before[0]after[length-1]=1 the array is shifted ,which prevents the inclusion of current index. Ex: int a[5]={10,4,8,3,9} before[0]=1 before[1]=10 before[2]=40 before[3]=320 before[4]=960 after[4]=1 after[3]=9 after[2]=27

Re: [algogeeks] Re: Finding max for all positions of a moving window

2010-09-21 Thread Naveen Agrawal
@Minotauraus Your algo is wrong Consider this case: 12 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 According to your algo 1)Max for first window =99,i.e,curr max=99 2)Compare with new element,i.e wlth element