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
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
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
@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
@ 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
@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
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:
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
@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
@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
10 matches
Mail list logo