Can you explain Kadane's algorithm to find sub array having maximum sum value for all negative array numbers?
For example:
Array - [ -10, -10, -10] should return -10. But normally Kadane's...
Type: Posts; User: sunil9211
Can you explain Kadane's algorithm to find sub array having maximum sum value for all negative array numbers?
For example:
Array - [ -10, -10, -10] should return -10. But normally Kadane's...
Well, i found the problem. FindMin and Findmax functions need to return root only. No casting necessary unless you are going to print max and min values.
struct node
{
int data;
struct node *left, *right;
};
struct node *root=NULL;
int main()
{
root=insert(root,100);
insert(root,80);
Solved! I made a silly mistake. i should have set the value of j as 97 not zero.
Every time when the if condition is true the value of count should be printed then become zero. but that's not happening, why?
OUTPUT:
j=99 count=3
j=104 count=104
j=98 count=98. Why the...
It takes a string input then terminates.
I can't declare initial size of string array as that depends on the user input and that can be of 10^50 size. What should i do?
#include<stdio.h>
int...
scanf("%10[^\n]s", name) or fgets(s, 10, stdin)?
In all possible cases when we take a string as input.
It works now. I forgot that function gets() will read only 9 char long string as its size is 10.
Thank you everyone! :biggrin:
I agree with you, but ever after initializing the variables it's giving wrong output. Why?
If we initialize c1=0, c2=0;
Still the answer is incorrect for any string that includes one or more blank spaces.
#include<string.h>
#include<stdio.h>
int main()
{
char s[10];
fgets(s,10,stdin);
func(s);
return 0;