Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Day2/C++/palindromeday2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s;
cin >> s;
string t = s;
reverse(s.begin(), s.end());
if(s.compare(t) == 0) cout << "Palindrome!";
else cout << "Not a palindrome";
return 0;
}
17 changes: 17 additions & 0 deletions Day2/C++/reverseday2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s;
cin >> s;
reverse(s.begin(), s.end());
cout <<s;
return 0;
}
54 changes: 51 additions & 3 deletions Day2/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![cover](./cover.png)
![cover](./cover.png)

# Day 2 -- String Reversal and Palindrome

Expand Down Expand Up @@ -224,7 +224,7 @@ public class Reverse {

## C++ Implementation

### [C++ Solution](./C++/reverseString.cpp)
### [Solution by @imkaka](./C++/reverseString.cpp)

```cpp
/*
Expand Down Expand Up @@ -255,6 +255,28 @@ return 0;
}
```

### [Solution by @divyakhetan](./C++/reverseday2.cpp)

```cpp
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s;
cin >> s;
reverse(s.begin(), s.end());
cout <<s;
return 0;
}
```

## Python Implementation

### [Solution 1](./Python/Reverse.py)
Expand Down Expand Up @@ -549,7 +571,9 @@ public class Palindrome2 {
}
```

### [C++ Implementation](./C++/checkPalindrome.cpp)
## C++ Implementation

### [Solution by @imkaka](./C++/checkPalindrome.cpp)

```cpp
/*
Expand Down Expand Up @@ -587,6 +611,30 @@ int main(){
}
```

### [Solution by @divyakhetan](./C++/palindromeday2.cpp)

```cpp
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s;
cin >> s;
string t = s;
reverse(s.begin(), s.end());
if(s.compare(t) == 0) cout << "Palindrome!";
else cout << "Not a palindrome";
return 0;
}
```

## Python Implementation

### [Solution 1](./Python/Palindrome.py)
Expand Down
23 changes: 23 additions & 0 deletions Day3/C++/hammingDistanceday3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1, s2;
cin >> s1 >> s2;
if(s1.length() != s2.length()) cout << "Enter strings of equal length";
else{
int count = 0;
for(int i = 0; i < s1.length(); i++){
if(s1[i] != s2[i]) count++;
}
cout << "The Hamming Distance is: " << count;
}
return 0;
}
30 changes: 29 additions & 1 deletion Day3/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Hamming](./cover.png)
![Hamming](./cover.png)

# Day 3 -- The Hamming Distance Problem

Expand Down Expand Up @@ -173,6 +173,34 @@ int main(){
}
```

### [hamingDistance](./C++/hammingDistanceday3.cpp)

```cpp
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1, s2;
cin >> s1 >> s2;
if(s1.length() != s2.length()) cout << "Enter strings of equal length";
else{
int count = 0;
for(int i = 0; i < s1.length(); i++){
if(s1[i] != s2[i]) count++;
}
cout << "The Hamming Distance is: " << count;
}
return 0;
}
```

## C Implementation

### [hamming.c](./C/hamming.c)
Expand Down
44 changes: 44 additions & 0 deletions day4/C++/MaxFreq.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1;
cin >> s1;
int freqlo[26];
memset(freqlo, 0, sizeof(freqlo));
int freqhi[26];
memset(freqhi, 0, sizeof(freqhi));
int max = 0;
char maxc;
//count for lowercase
for(int i = 0; i < s1.length(); i++){
if(s1[i] >= 'a' && s1[i] <= 'z'){
freqlo[s1[i] - 'a']++;
if(freqlo[s1[i] - 'a']> max){
max = freqlo[s1[i] - 'a'];
maxc = s1[i];
}
}

else if(s1[i] >= 'A' && s1[i] <= 'Z'){
freqhi[s1[i] - 'A']++;
if(freqhi[s1[i] - 'A']> max){
max = freqhi[s1[i] - 'A'];
maxc = s1[i];
}
}
}




cout << "Max freq is:" << max << " for " << maxc;
return 0;
}
20 changes: 20 additions & 0 deletions day4/C++/vowelday4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1;
cin >> s1;
int count = 0;
for(int i = 0; i < s1.length(); i++){
if(s1[i] == 'a' || s1[i] == 'e' ||s1[i] == 'i' || s1[i] == 'o' ||s1[i] == 'u') count++;
}
cout << "Vowels are:" << count;
return 0;
}
77 changes: 77 additions & 0 deletions day4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,33 @@ int main()

```

### [Solution](./C++/vowelday4.cpp)

```cpp
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1;
cin >> s1;
int count = 0;
for(int i = 0; i < s1.length(); i++){
if(s1[i] == 'a' || s1[i] == 'e' ||s1[i] == 'i' || s1[i] == 'o' ||s1[i] == 'u') count++;
}
cout << "Vowels are:" << count;
return 0;
}

```


## Python Implementation

### [Solution](./Python/partA_sol.py)
Expand Down Expand Up @@ -704,6 +731,56 @@ int main()
// Its called time-space trade off, which we generally do most times.
```

### [Solution](./C++/MaxFreq.cpp)

```cpp

/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1;
cin >> s1;
int freqlo[26];
memset(freqlo, 0, sizeof(freqlo));
int freqhi[26];
memset(freqhi, 0, sizeof(freqhi));
int max = 0;
char maxc;
//count for lowercase
for(int i = 0; i < s1.length(); i++){
if(s1[i] >= 'a' && s1[i] <= 'z'){
freqlo[s1[i] - 'a']++;
if(freqlo[s1[i] - 'a']> max){
max = freqlo[s1[i] - 'a'];
maxc = s1[i];
}
}

else if(s1[i] >= 'A' && s1[i] <= 'Z'){
freqhi[s1[i] - 'A']++;
if(freqhi[s1[i] - 'A']> max){
max = freqhi[s1[i] - 'A'];
maxc = s1[i];
}
}
}




cout << "Max freq is:" << max << " for " << maxc;
return 0;
}
```

## Python Implementation

### [Solution](./Python/partB_sol.py)
Expand Down
22 changes: 22 additions & 0 deletions day6/C++/Anagramday6.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s1, s2;
cin >> s1 >> s2;
if(s1.length() != s2.length()) cout << "Not of same length";
else{
sort(s1.begin(), s1.end());
sort(s2.begin(), s2.end());
if(s1.compare(s2) == 0) cout << "Anagrams!";
else cout << "Not anagrams";
}
return 0;
}
23 changes: 23 additions & 0 deletions day6/C++/capitaliseFirstday6.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @author:divyakhetan
* @date: 30/12/2018
*/


#include<bits/stdc++.h>
using namespace std;


int main(){
string s;
getline(cin, s);
s[0] = toupper(s[0]);
for(int i = 1; i < s.length(); i++){
if(s[i - 1] == ' '){
if(s[i] >= 'a' && s[i] <= 'z') s[i] = toupper(s[i]);
}
}

cout << s << endl;
return 0;
}
Loading