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

since syntax is  :-   char *strcat(char *restrict s1, const char *restrict
s2);

On Wed, Nov 14, 2012 at 7:38 PM, VINOD CHOUDHARY wrote:

> 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*
> *Motilal Nehru National Institute of Technology*
> *Allahabad[211004],UP.*
>
>  --
> 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] 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:

> #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
>
> since syntax is  :-   char *strcat(char *restrict s1, const char *restrict
> s2);
>
> On Wed, Nov 14, 2012 at 7:38 PM, VINOD CHOUDHARY wrote:
>
>> 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*
>> *Motilal Nehru National Institute of Technology*
>> *Allahabad[211004],UP.*
>>
>>  --
>> 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] 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 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] 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 Write Code"
Computer Science
Birla institute of Technology Mesra
*

-- 
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/-/tZZxNv9-OzgJ.
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] 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) for which,
sum[i]=sum[j] and j-i is  maximum (j>i)

(This is easy to see as,Let for substring  [i,j] the number of 1s is equal
to number of 0's ,then sum[i,j]=0 as per our algo, OR we can state that
sum[i-1]=sum[j],now for longest substring the difference should be maximum)

example:- 1 0 1 --> -1 1 -1 ---> sum array ::  0 -1 0 -1

take i=1and j=2,sum[i-1]=sum[j]=-1,and substring::string[1,2]= 1 0 (Answer)
4)Now,the above step can be done quickly using hashing(using array indexes)
in O(n).(If n<10^6)

On Sat, Aug 13, 2011 at 9:53 PM, Yasir  wrote:

> 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 traversed we have to find the max distance among two equal
> numbers in an array. (need to think on this problem as well)
>
> --
> 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/-/gWwbzXZ_B1sJ.
>
> 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,*
*Piyush Kapoor,*
*2nd year,CSE
IT-BHU*

-- 
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] 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 traversed we have to find the max distance among two equal 
numbers in an array. (need to think on this problem as well)

-- 
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/-/gWwbzXZ_B1sJ.
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] 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 longest seq
>
> Hope this could solve the problem.
>
> On Sat, Aug 13, 2011 at 1:56 PM, vicky S  wrote:
>
>> 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 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.
>>
>
>
>
> --
> Thanks and Regards,
> Raghavan KL
>
>  --
> 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.
>



-- 
Aditi Garg
Undergraduate Student
Electronics & Communication Divison
NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
Sector 3, Dwarka
New Delhi

-- 
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] 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 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 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.
>



-- 
Thanks and Regards,
Raghavan KL

-- 
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] string question

2010-05-16 Thread Navin Naidu
@Sharad: yup

On Sun, May 16, 2010 at 8:36 PM, Rohit Saraf wrote:

> @Navin: and that works ! :)
> @all : i am sure no heuristic/greedy strategy can be applied.
> @divya : did you check your array partitioning algorithm with my example !
>
> --
> Rohit Saraf
> Second Year Undergraduate,
> Dept. of Computer Science and Engineering
> IIT Bombay
> http://www.cse.iitb.ac.in/~rohitfeb14
>
>
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Thanks & Regards,

- NMN

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



Re: [algogeeks] string question

2010-05-16 Thread Rohit Saraf
@Navin: and that works ! :)
@all : i am sure no heuristic/greedy strategy can be applied.
@divya : did you check your array partitioning algorithm with my example !

--
Rohit Saraf
Second Year Undergraduate,
Dept. of Computer Science and Engineering
IIT Bombay
http://www.cse.iitb.ac.in/~rohitfeb14

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



Re: [algogeeks] string question

2010-05-16 Thread sharad kumar
@navin naidu
like LCS in CLRS???

On Sun, May 16, 2010 at 8:20 PM, divya jain wrote:

>   output ll be : e's
>
> On 16 May 2010 20:17, sharad kumar  wrote:
>
>> suppose if i give
>> Ssmall:es
>> Sbig:he's  a  algogeek and he's rocking
>> wat will be o/p?
>>
>>
>> On Sun, May 16, 2010 at 8:12 PM, divya  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 all characters in Ssmall.
>>>
>>> For example you are given Sbig = "hello what are you doing"
>>> Ssmall= "eo"
>>> answer is "ello"
>>>
>>> --
>>> 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
>>> algogeeks+unsubscr...@googlegroups.com
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> yezhu malai vaasa venkataramana Govinda Govinda
>>
>>  --
>> 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
>> 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 algoge...@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.
>



-- 
yezhu malai vaasa venkataramana Govinda Govinda

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



Re: [algogeeks] string question

2010-05-16 Thread Navin Naidu
use dp to solve this.

On Sun, May 16, 2010 at 8:17 PM, sharad kumar wrote:

> suppose if i give
> Ssmall:es
> Sbig:he's  a  algogeek and he's rocking
> wat will be o/p?
>
>
> On Sun, May 16, 2010 at 8:12 PM, divya  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 all characters in Ssmall.
>>
>> For example you are given Sbig = "hello what are you doing"
>> Ssmall= "eo"
>> answer is "ello"
>>
>> --
>> 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
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
>  --
> 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
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Thanks & Regards,

- NMN

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



Re: [algogeeks] string question

2010-05-16 Thread divya jain
  output ll be : e's

On 16 May 2010 20:17, sharad kumar  wrote:

> suppose if i give
> Ssmall:es
> Sbig:he's  a  algogeek and he's rocking
> wat will be o/p?
>
>
> On Sun, May 16, 2010 at 8:12 PM, divya  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 all characters in Ssmall.
>>
>> For example you are given Sbig = "hello what are you doing"
>> Ssmall= "eo"
>> answer is "ello"
>>
>> --
>> 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
>> algogeeks+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
>  --
> 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
> 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 algoge...@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] string question

2010-05-16 Thread sharad kumar
suppose if i give
Ssmall:es
Sbig:he's  a  algogeek and he's rocking
wat will be o/p?

On Sun, May 16, 2010 at 8:12 PM, divya  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 all characters in Ssmall.
>
> For example you are given Sbig = "hello what are you doing"
> Ssmall= "eo"
> answer is "ello"
>
> --
> 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
> algogeeks+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
yezhu malai vaasa venkataramana Govinda Govinda

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