
Assalamualaikum warahmatullah wabarakatuh( traditional Islamic greeting in Arabic "Assalamu alaikum": "Peace be upon you." "Wa rahmatullahi": "And the mercy of Allah." "Wa barakatuh": "And His blessings.") I’m Faraz Alam, and I’m documenting my journey through the world of software technology. Despite earning a master’s degree in Computer Applications and having access to opportunities provided by my tier-3 college, I struggled to take full advantage of them due to poor management and a less productive environment. This led to joblessness, primarily due to a lack of upskilling. Now, I am dedicated to enhancing my skills and knowledge with the aim of securing a valuable job offer from leading product-based companies, including those in the FAANG group (Facebook, Amazon, Apple, Netflix, Google) and other prominent tech giants. This documentation is not for self-promotion; rather, it is for anyone who is waiting for an opportunity but feels they lack the tools and skills required to overcome challenges. It’s a testament to the effort and responsibility needed to navigate the journey towards success when you take charge of your own path. Date: 31 July 2024, 07:25 AM This page will be updated regularly to reflect new achievements and milestones as I continue to build my career.
1) Basic about c++ string
char str[] = "Geeks";
string string_name = "Sample String";
//
Internal Representation:
String characters are internally stored as integers. This means:
Characters like 'A' to 'Z' are mapped to integer values 65 to 90.
Characters like 'a' to 'z' are mapped to integer values 97 to 122.
This contiguous mapping helps in programming tasks, such as comparing characters alphabetically.
For example, 'A' (65) is less than 'B' (66).
2) Check if string is palindrome or not
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s; // Input the string
int start = 0; // Pointer to the beginning of the string
int end = s.length() - 1; // Pointer to the end of the string
// Check for palindrome
while (start < end) {
if (s[start] != s[end]) {
cout << "No"; // Not a palindrome
return 0; // Exit the program
}
start++; // Move start pointer forward
end--; // Move end pointer backward
}
cout << "Yes"; // The string is a palindrome
return 0;
}
3) Check for anagram
Problem: Given two strings, check whether two strings are an anagram of each other.
Two strings are said to be an anagram of each other if they are just permutations of each other.
That is, the set of characters in both the strings must be the same, only the order of characters
can be different.
///
///
Method- 1 (sorting)
///
// C++ program to check whether two strings are anagrams
// of each other
#include <bits/stdc++.h>
using namespace std;
/* function to check whether two strings are anagram of
each other */
bool areAnagram(string str1, string str2)
{
// Get lengths of both strings
int n1 = str1.length();
int n2 = str2.length();
// If length of both strings is not same, then they
// cannot be anagram
if (n1 != n2)
return false;
// Sort both the strings
sort(str1.begin(), str1.end());
sort(str2.begin(), str2.end());
// Compare sorted strings
for (int i = 0; i < n1; i++)
if (str1[i] != str2[i])
return false;
return true;
}
// Driver code
int main()
{
string str1 = "test";
string str2 = "ttew";
// Function Call
if (areAnagram(str1, str2))
cout << "The two strings are anagram of each other";
else
cout << "The two strings are not anagram of each "
"other";
return 0;
}
Time Complexity: O(N*logN)
Auxiliary Space: O(1)
//
//Method- 2 (count characters)
// C++ program to check if two strings
// are anagrams of each other
#include <bits/stdc++.h>
using namespace std;
#define NO_OF_CHARS 256
/* function to check whether two strings are anagram of
each other */
bool areAnagram(char* str1, char* str2)
{
// Create 2 count arrays and initialize all values as 0
int count1[NO_OF_CHARS] = { 0 };
int count2[NO_OF_CHARS] = { 0 };
int i;
// For each character in input strings, increment count
// in the corresponding count array
for (i = 0; str1[i] && str2[i]; i++) {
count1[str1[i]]++;
count2[str2[i]]++;
}
// If both strings are of different length. Removing
// this condition will make the program fail for strings
// like "aaca" and "aca"
if (str1[i] || str2[i])
return false;
// Compare count arrays
for (i = 0; i < NO_OF_CHARS; i++)
if (count1[i] != count2[i])
return false;
return true;
}
/* Driver code*/
int main()
{
char str1[] = "geeksforgeeks";
char str2[] = "forgeeksgeeks";
// Function Call
if (areAnagram(str1, str2))
cout << "The two strings are anagram of each other";
else
cout << "The two strings are not anagram of each "
"other";
return 0;
}
Time Complexity : O(n)
Space Complexity : O(NO_OF_CHAR) = O(256) = O(1) (constant space use)
4) Reverse word in given string
// C++ program to reverse a string
#include <bits/stdc++.h>
using namespace std;
// Function to reverse words*/
void reverseWords(string s)
{
// temporary vector to store all words
vector<string> tmp;
string str = "";
for (int i = 0; i < s.length(); i++) {
// Check if we encounter space
// push word(str) to vector
// and make str NULL
if (s[i] == ' ') {
tmp.push_back(str);
str = "";
}
// Else add character to
// str to form current word
else
str += s[i];
}
// Last word remaining,add it to vector
tmp.push_back(str);
// Now print from last to first in vector
int i;
for (i = tmp.size() - 1; i > 0; i--)
cout << tmp[i] << " ";
// Last word remaining,print it
cout << tmp[0] << endl;
}
// Driver Code
int main()
{
string s = "i like this program very much";
reverseWords(s);
return 0;
}



