Re: [algogeeks] string question

2012-11-15 Thread shivendra singh
#include int main() { char *str ="Algogeeks google"; char *str1 = "GROUP"; printf("str is %s",str); printf("\nstr is %s",str1); (char *)strcat(str1,str); printf("\nstr1 is %s",str1); return 0; } o/p: str is Algogeeks google str is GROUP str1 is GROUPAlgogeeks google sinc

Re: [algogeeks] string question

2012-11-15 Thread shivendra singh
But remember that if you are using CPP then its better to allocate sufficient memory to str1 , since you are copying str into str1. if str is very big string it might give a core dump since the possiblity of illegal memory access arises. On Thu, Nov 15, 2012 at 3:33 PM, shivendra singh wrote: >

[algogeeks] string question

2012-11-15 Thread VINOD CHOUDHARY
hi guys!! why this program is giving SEGMENTATION FAULT main() { char *str ="Algogeeks google"; char *str1 = "GROUP"; printf("str is %s",str); printf("str is %s",str1); strcat(str1,str); printf("str is %s",str1); } -- *VINOD KUMAR CHOUDHARY* *Bachelor of Technology*

Re: [algogeeks] string matching problem

2012-09-03 Thread bharat b
why can't we change the question to sum=0 .. On Mon, Sep 3, 2012 at 12:57 PM, atul anand wrote: > above link was for reference , extending the logic was obvious :) :) > > > On Mon, Sep 3, 2012 at 11:22 AM, bharat b wrote: > >> @atul: question is to find the largest continuous sub array .. not ju

Re: [algogeeks] string matching problem

2012-09-03 Thread atul anand
above link was for reference , extending the logic was obvious :) :) On Mon, Sep 3, 2012 at 11:22 AM, bharat b wrote: > @atul: question is to find the largest continuous sub array .. not just > continuous sub array .. > > we can do this with same logic as mentioned in the above link.. we have to

Re: [algogeeks] string matching problem

2012-09-02 Thread bharat b
@atul: question is to find the largest continuous sub array .. not just continuous sub array .. we can do this with same logic as mentioned in the above link.. we have to traverse whole array.. even if we get the solution .. whenever we get the solution,update the "largest_subarray_start_index" an

Re: [algogeeks] string matching problem

2012-09-02 Thread atul anand
http://www.geeksforgeeks.org/archives/19267 On Mon, Sep 3, 2012 at 7:41 AM, Amitesh Singh wrote: > Given a array, find the largest contiguous sub-array having its sum equal > to N. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To p

[algogeeks] string matching problem

2012-09-02 Thread Amitesh Singh
Given a array, find the largest contiguous sub-array having its sum equal to N. -- 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 al

Re: [algogeeks] String comparison

2012-04-18 Thread Shiva Kumar
Hi Abhishek, You can use following string comparison function "strcmplogicalw" you can refer http://msdn.microsoft.com/en-us/library/windows/desktop/bb759947%28v=vs.85%29.aspx Regards, Shivakumar On Wed, Apr 18, 2012 at 9:16 AM, abhishek wrote: > Hi, > > I need to compare string into fo

[algogeeks] String comparison

2012-04-17 Thread abhishek
Hi, I need to compare string into following way. Can anyone provide me some insight or algorithm in c++. For example: "a5" < "a11"- because 5 is less than 11 "6xxx < 007asdf"- because 6 < 7 "00042Q < 42s" - because Q < s alphabetically "6 8" < "006 9"

[algogeeks] string comparsion

2012-04-17 Thread Abhishek Goswami
Hi, I need to compare string into following way. Can anyone provide me some insight or algorithm in c++. For example: "a5" < "a11"- because 5 is less than 11 "6xxx < 007asdf"- because 6 < 7 "00042Q < 42s" - because Q < s alphabetically "6 8" < "006 9" -

[algogeeks] string compress/expand

2011-10-02 Thread rahul sharma
Write a routine that takes input as a string such as "aabbccdef" and o/p "a2b2c2def" or "a4bd2g4" for "bdd" if i want to make a general program for this..cani do by checking the 2nd array item if it is a number then i will call a fxn expandelse i will

Re: [algogeeks] string permutation

2011-10-01 Thread Thayumanavar S
i have searched the archives.any give me algorithm with example...it would be great help..thnx in advance #include #include #include using namespace std; void permute(string inp, string oth) { if ( inp == "" ) { cout

Re: [algogeeks] string permutation

2011-10-01 Thread rahul sharma
i have searched the archives.any give me algorithm with example...it would be great help..thnx in advance On Sun, Oct 2, 2011 at 2:57 AM, Prakash D wrote: > if the string is like abcdef > then they will be numbered like 012345 and now we represent them in base 5 > numbering and also in sorte

Re: [algogeeks] string permutation

2011-10-01 Thread Prakash D
if the string is like abcdef then they will be numbered like 012345 and now we represent them in base 5 numbering and also in sorted order the next permutation is 012354 012435 012453 012534 012543 013245 and so on.. On Sat, Oct 1, 2011 at 4:11 PM, rahul sharma wrote: > guys plz xplain logic be

Re: [algogeeks] string cutting in c

2011-10-01 Thread shady
problem description ? any link to the problem ? On Sat, Oct 1, 2011 at 7:55 PM, Srividhya wrote: > hi frnds..can any of you pls tell how to cut strings in optimal > time..in dynamic programming.. > > thanx:) > > -- > You received this message because you are subscribed to the Google Groups > "Al

[algogeeks] string cutting in c

2011-10-01 Thread Srividhya
hi frnds..can any of you pls tell how to cut strings in optimal time..in dynamic programming.. thanx:) -- 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

[algogeeks] string permutation

2011-10-01 Thread rahul sharma
guys plz xplain logic behind the string permutation.n if we have duplicates that should program display the duplicates or notnyone plz tell the logic/code for this. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group

Re: [algogeeks] STRING help

2011-09-30 Thread rahul vatsa
c style string is just the char array which is null terminated. On Fri, Sep 30, 2011 at 1:27 AM, rahul sharma wrote: > what is c style string??n wats diff b/w c and c++ strings > representtaion.. > > -- > You received this message because you are subscribed to the Google Groups > "Algorit

[algogeeks] STRING help

2011-09-29 Thread rahul sharma
what is c style string??n wats diff b/w c and c++ strings representtaion.. -- 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

Re: [algogeeks] string problem

2011-09-20 Thread Prakash D
no.. each ans[s] is stored before returning.. so there is no recalculation of any substring On Sun, Sep 18, 2011 at 4:12 AM, Marcelo Amorim Menegali < mmeneg...@gmail.com> wrote: > *ans[s]=find(s+1,len-1);* >> if(s[0]<'3'&&s[1]<'7') >> *ans[s] = ans[s]+find(s+2,len-2);* > >

Re: [algogeeks] string problem

2011-09-17 Thread Marcelo Amorim Menegali
I think you're getting TLE because your solution calculate the same stuff over and over again. Look at this part: >else{ > *ans[s]=find(s+1,len-1);* > if(s[0]<'3'&&s[1]<'7') > *ans[s] = ans[s]+find(s+2,len-2);* >} Calculating find(s+1,len-1) imply that find(s

[algogeeks] string problem

2011-09-17 Thread cegprakash
i'm trying out this problem www.spoj.pl/problems/ACODE i'm getting TLE.. I donno y my recursion leads to tle #include #include #include #include using namespace std; map ans; map flags; long long find(char *s, int len){ if(flags[s]) return ans[s]; if(s[0]=='0') ans[s]=0;

Re: [algogeeks] String

2011-09-13 Thread shady
sorry, but first try doing it yourself. btw, code is also present in archives. On Tue, Sep 13, 2011 at 2:50 PM, guna sekaran wrote: > please write a code any one > > On Tue, Sep 13, 2011 at 2:06 PM, shady wrote: > > search archives, already done > > > > On Tue, Sep 13, 2011 at 1:39 PM, Anshul K

Re: [algogeeks] String

2011-09-13 Thread guna sekaran
Thanks to all On Tue, Sep 13, 2011 at 4:35 PM, Kapil Gupta wrote: > +1 Karthik > > On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R wrote: >> >> Something like this. >> >> >> stack S; >> void function(char *s) { >>    char *ptr=s; >>    while(*ptr++ !=' ') {} >>            *ptr = '\0';

Re: [algogeeks] String

2011-09-13 Thread Kapil Gupta
+1 Karthik On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R wrote: > Something like this. > > > stack S; > void function(char *s) { >char *ptr=s; >while(*ptr++ !=' ') {} >*ptr = '\0'; > S.push(s); // Will push the string till NULL into > the

Re: [algogeeks] String

2011-09-13 Thread Sanjay Rajpal
#include #include #include void Swap(char *a,char *b) { char c; c=*a; *a=*b; *b=c; } int main() { char input[100]; printf("Enter a string (Length < 100) : "); scanf("%[^\n]",input); //Reversing the string int len=strlen(input); int i=0,j=len-1; while(i < j) { Swap(input+i,input+

Re: [algogeeks] String

2011-09-13 Thread shashi kant
hey Karthik phodd diya yaar tune .tejas waale cha gaye On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R wrote: > Something like this. > > > stack S; > void function(char *s) { >char *ptr=s; >while(*ptr++ !=' ') {} >*ptr = '\0'; > S.push(s);

Re: [algogeeks] String

2011-09-13 Thread sagar sindwani
Awesome solution karthik R On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R wrote: > Something like this. > > > stack S; > void function(char *s) { >char *ptr=s; >while(*ptr++ !=' ') {} >*ptr = '\0'; > S.push(s); // Will push the string till

Re: [algogeeks] String

2011-09-13 Thread kARTHIK R
Something like this. stack S; void function(char *s) { char *ptr=s; while(*ptr++ !=' ') {} *ptr = '\0'; S.push(s); // Will push the string till NULL into the stack function(ptr+1); } // Pop from stack to get words Karthik R

Re: [algogeeks] String

2011-09-13 Thread guna sekaran
please write a code any one On Tue, Sep 13, 2011 at 2:06 PM, shady wrote: > search archives, already done > > On Tue, Sep 13, 2011 at 1:39 PM, Anshul Khandelwal > wrote: >> >> U can take command line argument in main >> main(int argc,char * argv[ ]) >> { for(i=argc-1,i>=0;i--) printf("%s ",argv[

Re: [algogeeks] String

2011-09-13 Thread shady
search archives, already done On Tue, Sep 13, 2011 at 1:39 PM, Anshul Khandelwal < anshul.dans1...@gmail.com> wrote: > U can take command line argument in main > main(int argc,char * argv[ ]) > { for(i=argc-1,i>=0;i--) printf("%s ",argv[i]); > > } > > > On Tue, Sep 13, 2011 at 12:05 AM, hary rath

Re: [algogeeks] String

2011-09-13 Thread Anshul Khandelwal
U can take command line argument in main main(int argc,char * argv[ ]) { for(i=argc-1,i>=0;i--) printf("%s ",argv[i]); } On Tue, Sep 13, 2011 at 12:05 AM, hary rathor wrote: > kapil : in your solution you are required extra O(n+n*sizeOf(int *)) both > memory to create a link list that really cos

Re: [algogeeks] String

2011-09-12 Thread hary rathor
kapil : in your solution you are required extra O(n+n*sizeOf(int *)) both memory to create a link list that really costly -- 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 unsu

Re: [algogeeks] String

2011-09-12 Thread Kapil Gupta
convert each word to a token in linked list than print the reversal. On Mon, Sep 12, 2011 at 11:54 PM, abhinav gupta wrote: > > First reverse the whole string then reverse the individual words .Simple ! > > > > On Mon, Sep 12, 2011 at 11:08 AM, guna sekaran wrote: > >> String Reverse: >> >> inpu

Re: [algogeeks] String

2011-09-12 Thread abhinav gupta
First reverse the whole string then reverse the individual words .Simple ! On Mon, Sep 12, 2011 at 11:08 AM, guna sekaran wrote: > String Reverse: > > input : > > welcome to all > > output: > > all to welcome > > -- > You received this message because you are subscribed to the Google Groups

[algogeeks] String

2011-09-12 Thread guna sekaran
String Reverse: input : welcome to all output: all to welcome -- 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+un

[algogeeks] String Problem

2011-08-30 Thread Navneet Gupta
Given two strings S1 and S2, Find whether another string S3 can formed by interleaving S1 and S2. Only constant space. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@google

Re: [algogeeks] String Reverse

2011-08-29 Thread Ankit Agarwal
void function(int start, int end){ if (start > end) return; int x= a[end]-a[start]; a[start] = a[start] + x; a[end] = a[end] - x; function(start+1, end-1); } main(){ scanf("%s", &a[0]); int len = strlen(a); function(0,len-1); printf("%s\n", a); } -- Ankit Ag

Re: [algogeeks] String Reverse

2011-08-29 Thread rajeev bharshetty
@karan :' Could you please come up with a code or algo for the same On Mon, Aug 29, 2011 at 7:38 PM, rajeev bharshetty wrote: > @Dheeraj : I think the question says no swapping. > > > On Mon, Aug 29, 2011 at 6:56 PM, Karan Thakral wrote: > >> use xor inplace of a swap...u wont require extra space

Re: [algogeeks] String Reverse

2011-08-29 Thread rajeev bharshetty
@Dheeraj : I think the question says no swapping. On Mon, Aug 29, 2011 at 6:56 PM, Karan Thakral wrote: > use xor inplace of a swap...u wont require extra space or memory... > printing isnt a solution... > > > On Mon, Aug 29, 2011 at 6:15 PM, Dheeraj Sharma < > dheerajsharma1...@gmail.com> wrote:

Re: [algogeeks] String Reverse

2011-08-29 Thread Karan Thakral
use xor inplace of a swap...u wont require extra space or memory... printing isnt a solution... On Mon, Aug 29, 2011 at 6:15 PM, Dheeraj Sharma wrote: > void rev_str(int i) > { > if(i==((length/2))) > return ; > rev_str(i+1); > SWAP(str[i],str[length-1-i],t); > } > > pas

Re: [algogeeks] String Reverse

2011-08-29 Thread Dheeraj Sharma
void rev_str(int i) { if(i==((length/2))) return ; rev_str(i+1); SWAP(str[i],str[length-1-i],t); } passing 0 as parameter... On Mon, Aug 29, 2011 at 5:43 PM, mani walia wrote: > aa chak code > > > #include > > #include > > void rev(char*); > > int main() > { > > > > rev

Re: [algogeeks] String Reverse

2011-08-29 Thread mani walia
aa chak code #include #include void rev(char*); int main() { rev("hello sexy how are you"); getch(); } void rev(char *t) { if(*t) { rev(t+1); } printf("%c",*t); } khush reh... lol On Mon, Aug 29, 2011 at 5:38 PM, saurabh singh wrote: > http://www.ideone.co

Re: [algogeeks] String Reverse

2011-08-29 Thread saurabh singh
http://www.ideone.com/kSaff On Mon, Aug 29, 2011 at 4:17 PM, rohit agarwal wrote: > Print the last character of a string and call the function recursively with > remaining string (of length (n-1)) > > > -- > * Thanks and Regards* > ┌─┐ > Rohit Agarwal > Final

Re: [algogeeks] String Reverse

2011-08-29 Thread rohit agarwal
Print the last character of a string and call the function recursively with remaining string (of length (n-1)) -- * Thanks and Regards* ┌─┐ Rohit Agarwal Final Year B.Tech (Information Technology) NIT Durgapur └───

[algogeeks] String Reverse

2011-08-29 Thread rShetty
Give an algorithm/C Code to reverse a string using a recursive function without swapping or using any extra memory? -- 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 unsubscrib

[algogeeks] String passing

2011-08-27 Thread raj kumar
modify(char a[],char *b) { a[0]='a'//gives runtime error why? b[0]='b'//gives runtime error } main() { char p[]="hello"; char *x="hello"; x[0]='x';//will give run time error i know why p[0]='p' //works fine i know why modify("string","pointer"); } why un function modify both the assi

[algogeeks] string confusion

2011-08-14 Thread Arshad Alam
program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#include 2.#include 3.void main() 4.{ 5.clrscr(); 6.char s[]="No two viruses"; 7.int i=0; 8.while(s[i]!=0) 9.{

Re: [algogeeks] String Question

2011-08-14 Thread rohit
Nice one.. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/ShfCI3o9YY0J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe fro

Re: [algogeeks] String Question

2011-08-14 Thread WgpShashank
@all I Went Through Similar Question Some Times back,i hope piyesh used the same idea, have a look @ Naive & efficient Algorithm for doing the same. http://shashank7s.blogspot.com/2011/06/wap-to-output-all-intervals-i-j-where.html * **Regards Shashank Mani "Computer Science Is Awesome So Why I Wr

Re: [algogeeks] string confusion

2011-08-14 Thread Dipankar Patro
@ Gaurav: in ASCII code : '\0' is actually 0, if you are confused with '0' and 0, first one the character and later one is Remember that '0' is not 0 in ASCII, rather value of '0' is 48. So they can be used in place of each other. [ Just expanding what Sagar is trying to say] On 14 August 2011 1

Re: [algogeeks] string confusion

2011-08-14 Thread sagar pareek
arshad u got my point or not? On Sun, Aug 14, 2011 at 1:16 PM, Arshad Alam wrote: > program is running smooth but I have one confusion at line number 8. > why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* > > > > 1.#include > 2.#include > 3.void main() > 4.{ > 5.c

[algogeeks] string confusion

2011-08-14 Thread Arshad Alam
program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#include 2.#include 3.void main() 4.{ 5.clrscr(); 6.char s[]="No two viruses"; 7.int i=0; 8.while(s[i]!=0) 9.{

Re: [algogeeks] string confusion

2011-08-13 Thread sagar pareek
gaurav he is asking why we are using 0 in place of '\0' in line "8" On Sun, Aug 14, 2011 at 10:51 AM, Gaurav Menghani wrote: > Well, this can have undefined behavior. Technically you should append > - First allocate memory for a string > - Then append the terminating char > > In this case, the m

Re: [algogeeks] string confusion

2011-08-13 Thread Gaurav Menghani
Well, this can have undefined behavior. Technically you should append - First allocate memory for a string - Then append the terminating char In this case, the memory location after the last character is set to zero, but then you do not have control over it. It may not be zero when you run it the

Re: [algogeeks] string confusion

2011-08-13 Thread sagar pareek
ascii value of '\0' is 0 so they can be used in place of each other On Sun, Aug 14, 2011 at 10:24 AM, Arshad Alam wrote: > program is running smooth but I have one confusion at line number 8. > why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* > > > > 1.#include > 2.#include >

[algogeeks] string confusion

2011-08-13 Thread Arshad Alam
program is running smooth but I have one confusion at line number 8. why it is *while(s[i]!=0)* instead of *while(s[i]!='\0')* 1.#include 2.#include 3.void main() 4.{ 5.clrscr(); 6.char s[]="No two viruses"; 7.int i=0; 8.while(s[i]!=0) 9.{

Re: [algogeeks] String Question

2011-08-13 Thread Piyush Kapoor
Here is my algo: 1)Replace all '0' with '1' and '1' with '-1'(.i.e, 1 0 1 ---> -1 1 -1) 2)Now take an array to calculate the sum of all elements from 1 to that index, which can be calculated as sum[i]=sum[i-1]+ar[i],take 0th element as 0. 3)Now the problem becomes finding two indices (say i,j) fo

Re: [algogeeks] String Question

2011-08-13 Thread Yasir
Me too didn't get Raghavan's algo... Pls explain.. It seems that above algo will find only longest sequence starting from index 0. Just a thought: Along with raghavan's algo, what if I keep and array_of_integers[string_length] and keep on storing the count in this array. Once string is trave

Re: [algogeeks] String Doubt

2011-08-13 Thread Rohit Srivastava
my bad only 3,4 On Sat, Aug 13, 2011 at 7:41 PM, rajeev bharshetty wrote: > 3,4 > > > On Sat, Aug 13, 2011 at 7:39 PM, Raman wrote: > >> In statement 2, isn't p pointing to const string, as we cannot modify the >> characters of the string. >> >> -- >> You received this message because you are su

Re: [algogeeks] String Question

2011-08-13 Thread aditi garg
@raghavan: can u explain wid an example plz On Sat, Aug 13, 2011 at 4:11 PM, Raghavan wrote: > >- Keep an counter for first stuck number(0/1) >- increment it, if you stuck on other number, start decrementing it >- if the counter becomes zero,note that seq >- finally take the lon

Re: [algogeeks] String Doubt

2011-08-13 Thread rajeev bharshetty
3,4 On Sat, Aug 13, 2011 at 7:39 PM, Raman wrote: > In statement 2, isn't p pointing to const string, as we cannot modify the > characters of the string. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the

Re: [algogeeks] String Doubt

2011-08-13 Thread Raman
In statement 2, isn't p pointing to const string, as we cannot modify the characters of the string. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/FU-nrcT

Re: [algogeeks] String Doubt

2011-08-13 Thread Rohit Srivastava
also 3,4 On Sat, Aug 13, 2011 at 7:30 PM, Rohit Srivastava wrote: > 2. > > > On Sat, Aug 13, 2011 at 7:24 PM, Raman wrote: > >> Which of the following statements are correct about the below >> declarations? >> *char *p = "Sanjay"; >> char a[] = "Sanjay";* 1: There is no difference in the declara

Re: [algogeeks] String Doubt

2011-08-13 Thread Rohit Srivastava
2. On Sat, Aug 13, 2011 at 7:24 PM, Raman wrote: > Which of the following statements are correct about the below declarations? > *char *p = "Sanjay"; > char a[] = "Sanjay";*1:There is no difference in the declarations and both > serve the same purpose.2:*p* is a non-const pointer pointing to a >

[algogeeks] String Doubt

2011-08-13 Thread Raman
Which of the following statements are correct about the below declarations? *char *p = "Sanjay"; char a[] = "Sanjay";*1:There is no difference in the declarations and both serve the same purpose.2:*p* is a non-const pointer pointing to a non-const string, whereas *a* is a const pointer pointing t

Re: [algogeeks] String Question

2011-08-13 Thread Raghavan
- Keep an counter for first stuck number(0/1) - increment it, if you stuck on other number, start decrementing it - if the counter becomes zero,note that seq - finally take the longest seq Hope this could solve the problem. On Sat, Aug 13, 2011 at 1:56 PM, vicky S wrote: > Given a

[algogeeks] String questions

2011-08-13 Thread vicky S
Given a string which has repeating pattern .Find the repeating pattern and the length of the pattern . Example: 123123123123123 output : 123 lenth is 3 1122222211 output : 112211 lenght is 6 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks"

[algogeeks] String Question

2011-08-13 Thread vicky S
Given a string which oly has 0's and 1's . Find the maximum largest substring which have equal no of 0's and 1's and give the length of the substring . whether it can be solved in DP ?? or any other soln ? for example : given string : 001101000 output :0101 -- You received this message becaus

Re: [algogeeks] string easy question

2011-08-02 Thread Vijay Khandar
Thanks Prateek.. On Tue, Aug 2, 2011 at 7:52 PM, prateek gupta wrote: > When the strings are equal then strcmp returns zero so your condition will > become if (0). > In order to correct it use > > if(strcmp(str1,str2)==0) > pritnf("equal"); > else > Unequal. > > On Tue, Aug 2, 2011 at 7:4

Re: [algogeeks] string easy question

2011-08-02 Thread prateek gupta
When the strings are equal then strcmp returns zero so your condition will become if (0). In order to correct it use if(strcmp(str1,str2)==0) pritnf("equal"); else Unequal. On Tue, Aug 2, 2011 at 7:47 PM, Vijay Khandar wrote: > #include > #include > #include > void main() > { > clrscr(); > char

[algogeeks] string easy question

2011-08-02 Thread Vijay Khandar
#include #include #include void main() { clrscr(); char str1[]="Hello"; char str2[]="Hello"; int i; if(strcmp(str1,str2)) printf ("\n Equal"); else printf("\n Unequal"); getch(); } Plz anyone explain me o/p with explanation. Vijay -- You received this message because you

Re: [algogeeks] String vs char array

2011-07-29 Thread sanjay ahuja
string class also stores the length of the string associated with it. When the string is printed, it prints it till the length but char array does not store any length variable. On Sat, Jul 30, 2011 at 10:36 AM, Grapher wrote: > string str("Hello"); > int main() > { >    str[3]=0; >    cout< } >

[algogeeks] String vs char array

2011-07-29 Thread Grapher
string str("Hello"); int main() { str[3]=0; cout

[algogeeks] String burn,measure time puzle

2011-07-08 Thread oppilas .
You have 2 pieces of string of different, unspecified length, and some matches. Each piece of string takes exactly an hour to burn, but the burn rate is not constant. . The strings have different burn rates, and of course you don't know the rates anyway. Using only the matches and the strings, mea

RE: [algogeeks] string matching

2011-06-23 Thread Navneet Gupta
String matching can be performed in linear time with KMP algorithm. could you say what more optimization you are looking for here? Sent from my Windows Phone -- From: prateek gupta Sent: 23/06/2011 11:17 To: algogeeks@googlegroups.com Subject: [algogeeks] string

Re: [algogeeks] string matching

2011-06-23 Thread aseem garg
Patrick!!! On Thu, Jun 23, 2011 at 11:29 AM, prateek gupta wrote: > yup, got it thanks!!! > > > On Thu, Jun 23, 2011 at 11:27 AM, sunny agrawal > wrote: > >> last line is >> *in worst case k=1 only 2*n comparisons will be there hence O(n)* >> >> >> >> On Thu, Jun 23, 2011 at 11:26 AM, sunny agraw

Re: [algogeeks] string matching

2011-06-22 Thread prateek gupta
yup, got it thanks!!! On Thu, Jun 23, 2011 at 11:27 AM, sunny agrawal wrote: > last line is > *in worst case k=1 only 2*n comparisons will be there hence O(n)* > > > > On Thu, Jun 23, 2011 at 11:26 AM, sunny agrawal > wrote: > >> Lets Consider the case of Naive matching in which at some shift s

Re: [algogeeks] string matching

2011-06-22 Thread sunny agrawal
last line is *in worst case k=1 only 2*n comparisons will be there hence O(n)* On Thu, Jun 23, 2011 at 11:26 AM, sunny agrawal wrote: > Lets Consider the case of Naive matching in which at some shift s first k > characters are matched and next character does not match so instead of > starting fr

Re: [algogeeks] string matching

2011-06-22 Thread sunny agrawal
Lets Consider the case of Naive matching in which at some shift s first k characters are matched and next character does not match so instead of starting from s+1 shift we can safely jump to s+k because all characters of pattern are distinct in worst case k=1 only an comparisons will be there hence

Re: [algogeeks] string matching

2011-06-22 Thread prateek gupta
In KMP there is a pre processing time of O(m). which is not there in naive. The question says to accelerate naive string matching. On Thu, Jun 23, 2011 at 11:19 AM, Piyush Sinha wrote: > > Read KMP algorithm.. > > > On Thu, Jun 23, 2011 at 11:17 AM, prateek gupta wrote: > >> In naive string matc

Re: [algogeeks] string matching

2011-06-22 Thread Piyush Sinha
Read KMP algorithm.. On Thu, Jun 23, 2011 at 11:17 AM, prateek gupta wrote: > In naive string matching how can the knowledge abt. pattern that it has all > different characters can be used to accelerate the algorithm to O(n) . > > -- > You received this message because you are subscribed to the

[algogeeks] string matching

2011-06-22 Thread prateek gupta
In naive string matching how can the knowledge abt. pattern that it has all different characters can be used to accelerate the algorithm to O(n) . -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread Apoorve Mohan
@sharma: dis has been explained to tiwari...ask him...:) On Fri, Jun 17, 2011 at 3:12 AM, DIPANKAR DUTTA wrote: > instead of calling swap(&ps[0],&ps[1]) can u try with swap(ps[0],ps[1]) or > swap(&ps[0][0],&ps[1][0]) ? > > On Fri, Jun 17, 2011 at 5:05 AM, udit sharma wrote: > >> #includevoid swap

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread Rohit Sindhu
#include void swap(char **p,char **q) { char *t; t=*p; *p=*q; *q=t; } int main(){ char *ps[2]={ "Hello", "Good Morning", }; swap( &ps[0] , &ps[1]); printf("%s \t %s\n",ps[0],ps[1]); return 0; } This one breaks the ice ... as you have to change the contents of the array wh

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread Rohit Sindhu
The function swap just swaps it's local copy of pointers which does not mean that it swap array elements. You have to do it explicitly. On Fri, Jun 17, 2011 at 3:17 AM, udit sharma wrote: > Ohh Sry... The qus was: > > >> #includevoid swap(char *,char *);int main(){char *ps[2]={ >>>

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread udit sharma
Ohh Sry... The qus was: > #includevoid swap(char *,char *);int main(){char *ps[2]={ >> "Hello", >> "Good Mornning", >> };swap(ps[0],ps[1]);printf("%s \t %s\n",ps[0],ps[1]);return 0;} >> void swap(char *p,char *q){char *t;t=p;p=q;q=t;} >> >> >> why the output is: >>

Re: [algogeeks] String Swapping Problem

2011-06-16 Thread DIPANKAR DUTTA
instead of calling swap(&ps[0],&ps[1]) can u try with swap(ps[0],ps[1]) or swap(&ps[0][0],&ps[1][0]) ? On Fri, Jun 17, 2011 at 5:05 AM, udit sharma wrote: > #includevoid swap(char *,char *);int main(){char *ps[2]={ > "Hello", > "Good Mornning", > };swap(&ps[0],&p

[algogeeks] String Swapping Problem

2011-06-16 Thread udit sharma
#includevoid swap(char *,char *);int main(){char *ps[2]={ "Hello", "Good Mornning", };swap(&ps[0],&ps[1]);printf("%s \t %s\n",ps[0],ps[1]);return 0;} void swap(char *p,char *q){char *t;t=p;p=q;q=t;} why the output is: HelloGood Mornning -- Regar

[algogeeks] String of Max Length Which Repeats More Then Onep

2011-02-24 Thread bittu
Given a string (assume there no spaces or punctuations), write a program that returns the max. length of the string that has repeated more than once. Thanks Shashank -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, sen

[algogeeks] String Operation

2011-02-16 Thread bittu
Given a group of strings, find a string by concatenating all the strings in any order which produces the lexicographically smallest string. For e.g strings are acc bcc abb So the string formed should be abbaccbcc Thanks Shashank -- You received this message because you are subscribed to the Goog

Re: [algogeeks] string

2010-07-18 Thread Ashish Goel
http://en.wikipedia.org/wiki/Levenshtein_distance Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Sun, Jul 18, 2010 at 6:08 PM, Ratnesh Thakur wrote: > Given a string A, and a string B, and a dictionary, how would you > convert A to B in the min

[algogeeks] string

2010-07-18 Thread Ratnesh Thakur
Given a string A, and a string B, and a dictionary, how would you convert A to B in the minimum no of operations, given that: i) All the intermediate words must be from the dictionary ii) An ‘operation’ is defined as: a) Delete any character from a string ex dog → do b) Insert any character int

[algogeeks] String Problem

2010-07-11 Thread amit
given a string find the number of distinct substrings of the string. ex: input-> output-> 4(a, aa, aaa, ) input->abcd output->10(a, b, c, d, ab, bc, cd, abc, bcd, abcd) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this

[algogeeks] string manipulation

2010-06-30 Thread jalaj jaiswal
Remove Repeated Characters in a string in a language of 2^40 characters :-? -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge..

Re: [algogeeks] String Problem

2010-06-27 Thread Anand
Yes exactly... On Sat, Jun 26, 2010 at 9:57 PM, Anand wrote: > http://codepad.org/NDAeIpxR > Here is code for it > > > On Sat, Jun 26, 2010 at 9:54 PM, Anand wrote: > >> you can use Longest common subsequence algorithm to solve it. >> >> >> >> On Sat, Jun 26, 2010

Re: [algogeeks] String Problem

2010-06-26 Thread Anand
http://codepad.org/NDAeIpxR Here is code for it On Sat, Jun 26, 2010 at 9:54 PM, Anand wrote: > you can use Longest common subsequence algorithm to solve it. > > > > On Sat, Jun 26, 2010 at 4:04 PM, amit wrote: > >> You r given a large string of characters lets call

Re: [algogeeks] String Problem

2010-06-26 Thread Anand
you can use Longest common subsequence algorithm to solve it. On Sat, Jun 26, 2010 at 4:04 PM, amit wrote: > You r given a large string of characters lets call it Sbig. Then there > is a small set of characters lets call it Ssmall. You have to find > smallest substring of Sbig which contains a

[algogeeks] String Problem

2010-06-26 Thread amit
You r given a large string of characters lets call it Sbig. Then there is a small set of characters lets call it Ssmall. You have to find smallest substring of Sbig which contains all characters in Ssmall. For example you are given Sbig = "hello what are you doing" Ssmall= "eo" answer is "ello" 2

  1   2   >