Re: [algogeeks] Programs

2011-09-19 Thread kartik sachan
@bharatkumar  i think u r  in thinking oder in lexicographic order .but in
question its not the same...

we have print the according to the sentence not according to dictonary

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-17 Thread bharatkumar bagana
@karthick:
as per u'r code... for ex: total is i/p---o/p will be 'l' not 'o' since 'l'
comes before to 'o' ...

On Thu, Sep 15, 2011 at 10:55 PM, kartik sachan wrote:

> soluntion for 1ST question is :http://ideone.com/LSOj6
>
> # include# includechar checknonrepeat(char *a,int *b,int n){
> int i;
> for(i=0;i {
> if(b[a[i]]==1)
> break;
> }return a[i];}int main(){
> int  b[300]={0};
> char a[]="teeter";
> int n=strlen(a);
> int i;
> for(i=0;i b[a[i]]++;
> printf("NON REPEATED CHAR=%c\n",checknonrepeat(a,b,n));
> return 0;}
>
>
> complex O(lenght of string)
>
> plz correct me if i am wrong..
>
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 

**Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees
*BharatKumar Bagana*
**http://www.google.com/profiles/bagana.bharatkumar
*
Mobile +91 8056127652*


-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-15 Thread kartik sachan
soluntion for 1ST question is :http://ideone.com/LSOj6

# include# includechar checknonrepeat(char *a,int
*b,int n){
int i;
for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-12 Thread wellwisher
#include#include#includeusing namespace std;
 int main(){int temp1[256];int i=0;char str[40] = "Battle of the
vowels: Hawaii vs. Gronzy";char temp[6] = "aeiou";
 for(i=0;i<256;i++)
temp1[i] = 0;

i=0;while(temp[i]){
temp1[(int)temp[i]] = 1;
i++;}
i=0;while(str[i]){if(temp1[(int)str[i]] == 1){
str[i] = -1;}
i++;}for(unsigned i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-12 Thread wellwisher
#include#include#includeusing namespace std;
 int main(){int temp1[256];int i=0;char str[40] = "Battle of the
vowels: Hawaii vs. Gronzy";char temp[6] = "aeiou";
 for(i=0;i<256;i++)
temp1[i] = 0;

i=0;while(temp[i]){
temp1[(int)temp[i]] = 1;
i++;}
i=0;while(str[i]){if(temp1[(int)str[i]] == 1){
str[i] = -1;}
i++;}for(unsigned i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-12 Thread bharatkumar bagana
For 2nd question : @Ishan : U'r code is not giving compilation error in gcc
.. it is going into infinite loop ..
This is working fine ..
#include
#include

int main()
{
int temp1[256];
int i=0;
char str[50] = "Battle of the vowels: Hawaii vs. Gronzy";
char temp[6] = "aeiou";

for(i=0;i<256;i++)
temp1[i] = 0;
 i=0;
while(temp[i])
{
temp1[temp[i]] = 1;
i++;
}
i=0;
int flag=0,tail=0;
while(str[i])
{
if(temp1[str[i]] != 1)
str[tail++] = str[i];
i++;
}
str[tail]='\0';
 printf("%s", str);
}
output : Bttl f th vwls: Hw vs. Grnzy

On Sun, Sep 11, 2011 at 1:27 PM, sukran dhawan wrote:

> #include
> #include
> #include
> using namespace std;
> int main()
> {
> char answer;
> bitset<26> charset;
> bitset<26> repeat;
> char a[]={'s','a','s','a','b','v','s','a'};
> #ifdef TEST
> gets(a);
> #endif
> int i;
> for(i=0;a[i]!='\0';i++){
> if(charset.test(a[i]-'a')) {
> repeat.set(a[i]-'a');
> }
>
> charset.set(a[i]-'a');
> }
>
> for(int j=0;j {
> if(!repeat.test(a[j]-'a')){
> cout< return 0;
> }
> }
>
> cerr<<"No non repeating Character"<  return 0;
>
>
> On Sun, Sep 11, 2011 at 9:16 PM, Kamakshii Aggarwal  > wrote:
>
>> @neha:can u pls explain ur method?
>>
>>
>> On Sun, Sep 11, 2011 at 9:09 PM, sukran dhawan wrote:
>>
>>> ya +1 to neha use bitset concept in c++
>>>
>>>
>>> On Sun, Sep 11, 2011 at 8:24 PM, Neha Singh 
>>> wrote:
>>>
 for ques 1 use bit manipulation
 its more efficient

 --
 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
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>  --
>>> 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
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards,
>> Kamakshi
>> kamakshi...@gmail.com
>>
>>  --
>> 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
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 

**Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees
*BharatKumar Bagana*
**http://www.google.com/profiles/bagana.bharatkumar
*
Mobile +91 8056127652*


-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread sukran dhawan
#include
#include
#include
using namespace std;
int main()
{
char answer;
bitset<26> charset;
bitset<26> repeat;
char a[]={'s','a','s','a','b','v','s','a'};
#ifdef TEST
gets(a);
#endif
int i;
for(i=0;a[i]!='\0';i++){
if(charset.test(a[i]-'a')) {
repeat.set(a[i]-'a');
}

charset.set(a[i]-'a');
}

for(int j=0;jwrote:

> @neha:can u pls explain ur method?
>
>
> On Sun, Sep 11, 2011 at 9:09 PM, sukran dhawan wrote:
>
>> ya +1 to neha use bitset concept in c++
>>
>>
>> On Sun, Sep 11, 2011 at 8:24 PM, Neha Singh 
>> wrote:
>>
>>> for ques 1 use bit manipulation
>>> its more efficient
>>>
>>> --
>>> 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
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards,
> Kamakshi
> kamakshi...@gmail.com
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread Kamakshii Aggarwal
@neha:can u pls explain ur method?

On Sun, Sep 11, 2011 at 9:09 PM, sukran dhawan wrote:

> ya +1 to neha use bitset concept in c++
>
>
> On Sun, Sep 11, 2011 at 8:24 PM, Neha Singh wrote:
>
>> for ques 1 use bit manipulation
>> its more efficient
>>
>> --
>> 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
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread sukran dhawan
ya +1 to neha use bitset concept in c++

On Sun, Sep 11, 2011 at 8:24 PM, Neha Singh wrote:

> for ques 1 use bit manipulation
> its more efficient
>
> --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread Neha Singh
for ques 1 use bit manipulation
its more efficient

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread parag khanna
use the concept of counting ... store the count in an array ... similar to
counting sort ... if count is 1 in an array ... the first index is returned
.. which wil give the non repeating element

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread teja bala
//first one
#include
main()
{
char *a="total";
int n=5;
int i,j,flag=1;
for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread sukran dhawan
int a[256] = {0};

int i;
for(i=0;str[i];i++)
a[str[i]]++;

for(i=0;str[i];i++)
{
if(a[str[i]] == 1)
{
printf("%c",str[i]);
break;
}
}

hope i am clear

On Sun, Sep 11, 2011 at 5:56 PM, Ishan Aggarwal <
ishan.aggarwal.1...@gmail.com> wrote:

> How will it work>?
>
>
> On Sun, Sep 11, 2011 at 5:53 PM, sukran dhawan wrote:
>
>> 1.use character count to record frequencey of occurences // initialise
>> array to 0
>> 2. for(i=0;str[i];i++)
>> {
>>if(count[str[i]] == 0) // first repeated character break;
>> }
>>
>>  On Sun, Sep 11, 2011 at 5:43 PM, Ishan Aggarwal <
>> ishan.aggarwal.1...@gmail.com> wrote:
>>
>>>  {Please solve the following questions :-
>>>
>>> 1.) Find first non repeated character.
>>>
>>> eg. total --> o
>>> teeter --> r
>>>
>>> 2.) Remove specified letters from a string.
>>>
>>> input --> "Battle of the vowels: Hawaii vs. Gronzy" , "aeiou"
>>>
>>> output --> "Bttle f th vwls: Hw vs. Grnzy"
>>>
>>> What is the problem in this solution ... Its giving compilation error.
>>>
>>>
>>> #include#include
>>>  void main(){int temp1[256];int i=0;char str[40] = "Battle of the vowels: 
>>> Hawaii vs. Gronzy";char temp[6] = "aeiou";
>>>  for(i=0;i<256;i++)
>>> temp1[i] = 0;
>>>
>>> i=0;while(temp[i]){
>>> temp1[temp[i]] = 1;
>>> i++;}
>>> i=0;while(str[i]){if(temp1[str[i]] == 1){
>>> str[i] = str[i+1];
>>> i--;}
>>> i++;}printf 
>>> ("%s", 
>>> str);}
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Kind Regards
>>> Ishan Aggarwal
>>> [image: Aricent Group]
>>> Presidency Tower-A, M.G.Road,Sector-14
>>> Gurgaon,Haryana.122015 INDIA
>>> Phone : +91-9654602663
>>> ishan2.aggar...@aricent.com 
>>>
>>>  --
>>> 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
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> 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
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Kind Regards
> Ishan Aggarwal
> [image: Aricent Group]
> Presidency Tower-A, M.G.Road,Sector-14
> Gurgaon,Haryana.122015 INDIA
> Phone : +91-9654602663
> ishan2.aggar...@aricent.com 
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread Ishan Aggarwal
How will it work>?

On Sun, Sep 11, 2011 at 5:53 PM, sukran dhawan wrote:

> 1.use character count to record frequencey of occurences // initialise
> array to 0
> 2. for(i=0;str[i];i++)
> {
>if(count[str[i]] == 0) // first repeated character break;
> }
>
> On Sun, Sep 11, 2011 at 5:43 PM, Ishan Aggarwal <
> ishan.aggarwal.1...@gmail.com> wrote:
>
>> {Please solve the following questions :-
>>
>> 1.) Find first non repeated character.
>>
>> eg. total --> o
>> teeter --> r
>>
>> 2.) Remove specified letters from a string.
>>
>> input --> "Battle of the vowels: Hawaii vs. Gronzy" , "aeiou"
>>
>> output --> "Bttle f th vwls: Hw vs. Grnzy"
>>
>> What is the problem in this solution ... Its giving compilation error.
>>
>>
>> #include#include
>>  void main(){int temp1[256];int i=0;char str[40] = "Battle of the vowels: 
>> Hawaii vs. Gronzy";char temp[6] = "aeiou";
>>  for(i=0;i<256;i++)
>> temp1[i] = 0;
>>
>> i=0;while(temp[i]){
>> temp1[temp[i]] = 1;
>> i++;}
>> i=0;while(str[i]){if(temp1[str[i]] == 1){
>> str[i] = str[i+1];
>> i--;}
>> i++;}printf 
>> ("%s", 
>> str);}
>>
>>
>>
>>
>>
>>
>> --
>> Kind Regards
>> Ishan Aggarwal
>> [image: Aricent Group]
>> Presidency Tower-A, M.G.Road,Sector-14
>> Gurgaon,Haryana.122015 INDIA
>> Phone : +91-9654602663
>> ishan2.aggar...@aricent.com 
>>
>>  --
>> 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
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Kind Regards
Ishan Aggarwal
[image: Aricent Group]
Presidency Tower-A, M.G.Road,Sector-14
Gurgaon,Haryana.122015 INDIA
Phone : +91-9654602663
ishan2.aggar...@aricent.com 

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Programs

2011-09-11 Thread sukran dhawan
1.use character count to record frequencey of occurences // initialise array
to 0
2. for(i=0;str[i];i++)
{
   if(count[str[i]] == 0) // first repeated character break;
}

On Sun, Sep 11, 2011 at 5:43 PM, Ishan Aggarwal <
ishan.aggarwal.1...@gmail.com> wrote:

> {Please solve the following questions :-
>
> 1.) Find first non repeated character.
>
> eg. total --> o
> teeter --> r
>
> 2.) Remove specified letters from a string.
>
> input --> "Battle of the vowels: Hawaii vs. Gronzy" , "aeiou"
>
> output --> "Bttle f th vwls: Hw vs. Grnzy"
>
> What is the problem in this solution ... Its giving compilation error.
>
>
> #include#include
>  void main(){int temp1[256];int i=0;char str[40] = "Battle of the vowels: 
> Hawaii vs. Gronzy";char temp[6] = "aeiou";
>  for(i=0;i<256;i++)
> temp1[i] = 0;
>
> i=0;while(temp[i]){
> temp1[temp[i]] = 1;
> i++;}
> i=0;while(str[i]){if(temp1[str[i]] == 1){
> str[i] = str[i+1];
> i--;}
> i++;}printf 
> ("%s", 
> str);}
>
>
>
>
>
>
> --
> Kind Regards
> Ishan Aggarwal
> [image: Aricent Group]
> Presidency Tower-A, M.G.Road,Sector-14
> Gurgaon,Haryana.122015 INDIA
> Phone : +91-9654602663
> ishan2.aggar...@aricent.com 
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.