Solution for Problem 4:
#includeiostream
#define size 10 //size = sizeof(arr);
#define max 8 //max = maxof(arr[])+1;
using namespace std;
int main()
{
int arr[] = {2,4,6,4,6,3,5,1,5,7}, hasharr[max] = {0}, i, sum=8;
for(i=0; isize; i++)
hasharr[arr[i]] = 1;
for long strings, the values will be larger.
a simple approach could be to store occurrence of each char of both the
strings in an integer array of size 26 and if both the arrays are same then
the two strings are anagrams.
--
You received this message because you are subscribed to the
++)
if(rep_char1[i] != rep_char2[i])
{
coutBoth are not anagram of each other.;
return 0;
}
coutBoth are anagram of each other.;
}
return 0;
}
--
Siddharth Kumar
BE 4th year, Computer Engineering
(Delhi College
#includeiostream
#define ARR_LEN 5
using namespace std;
int main()
{
int int_arr[ARR_LEN], k, min, max, x, temp, i;
for(i=0; iARR_LEN; i++)
cinint_arr[i];
coutEnter k: ;
cink;
min = (1k)-1;
max = min(ARR_LEN-k);
for(x=min; x=max;
#includeiostream
#includestring.h
using namespace std;
int main()
{
char str[] = viikk;
int rep[26] = {0};
int i, len = strlen(str);
int num_odd=0;
for(i=0; ilen; i++)
rep[(str[i]-'a')]++;
for(i=0; i26; i++)
{
if((rep[i] != 0) (rep[i]%2 ==1))
1st: xy
2nd: yx
3rd: x0y
--
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,