Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos detected by codespell #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Algorithm/Bit manipulation/Binary_facts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ example:
4 -> 100
5 -> 101

So, we can quickly check a number is odd or not using binary ans(&).
So, we can quickly check a number is odd or not using binary and(&).
if the result is non-zero then the given number is odd, else the result is 0 then even
2 changes: 1 addition & 1 deletion Algorithm/Bit manipulation/ip_hash.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Difference between logical & arithmatic shift ->
//Difference between logical & arithmetic shift ->
// https://stackoverflow.com/questions/44694957/the-difference-between-logical-shift-right-arithmetic-shift-right-and-rotate-r
//Logical shift correspond to (left-shift) multiplication by 2, (right-shift) integer division by 2

Expand Down
4 changes: 2 additions & 2 deletions Algorithm/Dynamic Programming/Factorial/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#### As solving Factorial is a non-overloaping problem, so dynamic programming won't help us here, but we can dynamic approch for series of factorial (1! + 2! + 3! + 4!)
#### For regular approch go to -> [Sazin's github](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/miscellaneous/Factorial)
#### As solving Factorial is a non-overloaping problem, so dynamic programming won't help us here, but we can dynamic approach for series of factorial (1! + 2! + 3! + 4!)
#### For regular approach go to -> [Sazin's github](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/miscellaneous/Factorial)
2 changes: 1 addition & 1 deletion Algorithm/Dynamic Programming/Fibonacci/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
### Fibonacci regular loop & recursive approch -> [Solution](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/miscellaneous/Fibonacci).
### Fibonacci regular loop & recursive approach -> [Solution](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/miscellaneous/Fibonacci).
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Solution {
int max_end = 0, max_sum = INT_MIN;

// we can also get the subarray starting & ending value,
// comment out commnet statement and get the result.
// comment out comment statement and get the result.
// int start = 0, stop = 0;

for(int i=0; i<nums.size(); i++) {
Expand Down
4 changes: 2 additions & 2 deletions Algorithm/Dynamic Programming/Test/dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ int main(){
memo[i] = -1;
}
scanf("%d %d %d %d", &n, &a, &b, &c);
int ans = find_nth_term(n, a, b, c);
int and = find_nth_term(n, a, b, c);

printf("%d", ans);
printf("%d", and);
return 0;
}

4 changes: 2 additions & 2 deletions Algorithm/Dynamic Programming/Test/recursion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ int main(){
int n, a, b, c;

scanf("%d %d %d %d", &n, &a, &b, &c);
int ans = find_nth_term(n, a, b, c);
printf("%d", ans);
int and = find_nth_term(n, a, b, c);
printf("%d", and);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions Algorithm/Pattern Maching/KMP/KMP(soi).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ void patAttery(string s, int array[]){
j++;
}
else{
//If i == 0, that means i already in first postion, so just have to increase the j.
//If i == 0, that means i already in first position, so just have to increase the j.
if (i == 0){
j++;
}
//If not, then backtrack until you find a match or come to the 0th postion.
//If not, then backtrack until you find a match or come to the 0th position.
else{
while (i > 0){
i = array[i - 1];
Expand Down
4 changes: 2 additions & 2 deletions Algorithm/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## Floyed cycle detection algorithm....
- In case of measuring the loop length we can use this algorithm.
- uVa 350 sudo random number generation problem solve with this algorthm. where in this problem we have find out when the generated number will repeat again because in computer generated random number is bounded by modulus
- uVa 350 sudo random number generation problem solve with this algorithm. where in this problem we have find out when the generated number will repeat again because in computer generated random number is bounded by modulus
- You can understand the problem if you see the problem -> https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=286


- One thing I observe when solve this problem, as we know the speed of fast pointer is twice than the slow pointer, so if there is loop then when the slow pointer reaches at the end of list then fast pointer also reaches to that position by it 2nd iteration. As there is loop or the number reapeated after a time, so when fast pointer 1st time reaches at the end of loop, then it's again get the number in where it start it's journey, which will ignite fast pointer 2nd iteration.
- One thing I observe when solve this problem, as we know the speed of fast pointer is twice than the slow pointer, so if there is loop then when the slow pointer reaches at the end of list then fast pointer also reaches to that position by it 2nd iteration. As there is loop or the number repeated after a time, so when fast pointer 1st time reaches at the end of loop, then it's again get the number in where it start it's journey, which will ignite fast pointer 2nd iteration.

Another thing when the fast pointer reaches at the end then the slow pointer will be in the middle of the list because you know fast pointer has twice speed than the slow pointer. After then fast pointer reaches end of the list, as list has loop or reapeted number it will start it 2nd iteration, on the other hand slow pointer start it's journey to the second half. And as fast pointer has speed twice of slow, it will be at the end of the list when the slow pointer also in the end of list. And both pointer value will match.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Gretest common divisor
### [Read Wikipedia for better explaination](https://en.wikipedia.org/wiki/Greatest_common_divisor)
### [Read Wikipedia for better explanation](https://en.wikipedia.org/wiki/Greatest_common_divisor)
14 changes: 7 additions & 7 deletions Algorithm/Sorting/Couting sort/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
https://www.youtube.com/watch?v=uvOe510RmWc&t=717s
---- This video explaination is good. Please see full video.
---- This video explanation is good. Please see full video.

#### Couting sort
#### Counting sort

<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Couting%20sort/1.png" width="60%">
<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Counting%20sort/1.png" width="60%">

1. First we have make two arrays, one for counting each elements in the array, another for storing the
output.


2. Count each element from the given array and store in the count array.
3.
<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Couting%20sort/2.png" width="60%">
<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Counting%20sort/2.png" width="60%">

3. Next add first element with next element & put in the next element array index. This will give us the
position of that value from where to where.
Like look at this below array, here in index 1 we have a value 2, that means the index 1 actullay represent element 1, and this element 1 will be store in first 2 position (0 and 1),
Like look at this below array, here in index 1 we have a value 2, that means the index 1 actually represent element 1, and this element 1 will be store in first 2 position (0 and 1),
the next index is 2, which have value 3, this has difference (3 - 2 = 1) which means it have only 1 value, which location is next (so after 0 and 1) it will be 2.

<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Couting%20sort/3.png" width="60%">
<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Counting%20sort/3.png" width="60%">


4.


<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Couting%20sort/4.png" width="60%">
<img src="https://github.com/SazinSamin/prgramming_problem_solving/blob/main/Algorithm/Sorting/Counting%20sort/4.png" width="60%">
2 changes: 1 addition & 1 deletion Algorithm/Sorting/Heap_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <iostream>
using namespace std;

//Swaping two elements
//Swapping two elements
void swap(int *a, int *b){
int temp = *a;
*a = *b;
Expand Down
2 changes: 1 addition & 1 deletion Algorithm/Sorting/Merge_Sort/Merge_Sort.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Merge sort implementaion
//Merge sort implementation
//This code sometimes crash for small data
//And give undefined result

Expand Down
2 changes: 1 addition & 1 deletion Algorithm/Sorting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Link -> MyCodeSchool https://www.youtube.com/watch?v=COk73cpQbFQ&list=PL2_aWCzGM
linear complexity is the need.

#### -Practical information.
Sorting in Dart progamming language implementated as when the difference between right & left value is 32 or less, they use regular insertion sort. But if the difference avobe the level then thay use Dual-Pivot Quicksort algorithm.
Sorting in Dart programming language implemented as when the difference between right & left value is 32 or less, they use regular insertion sort. But if the difference avobe the level then they use Dual-Pivot Quicksort algorithm.
2 changes: 1 addition & 1 deletion Algorithm/miscellaneous/Factorial/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Factorial
### Dynamic programming approch -> [Sazin's Git](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/Dynamic%20Programming/Factorial)
### Dynamic programming approach -> [Sazin's Git](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/Dynamic%20Programming/Factorial)
4 changes: 2 additions & 2 deletions Algorithm/miscellaneous/Fibonacci/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fibonacci

Here we have regular solving approch. For optimization
### Got to [Dynamic Programming Approch](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/Dynamic%20Programming/Fibonacci)
Here we have regular solving approach. For optimization
### Got to [Dynamic Programming Approach](https://github.com/SazinSamin/Samin_Reading_Room/tree/main/Algorithm/Dynamic%20Programming/Fibonacci)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using namespace std;


// this algorithm is not perfect for detecting integer overflow,
// it detect only when singed integer turrned into negetive but if signed integer again turn into positive
// it detect only when signed integer turrned into negetive but if signed integer again turn into positive
// after rounding it's negetive portion, it's failed to detect the overflow.

int isOverFlow(int* result, int a, int b){
Expand Down
2 changes: 1 addition & 1 deletion Bug hunting/Floating point exception
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
If you divide a number by 0 then,
C complier will generate "floating point exception".
C compiler will generate "floating point exception".
Dart compiler gives us "infinity"
6 changes: 3 additions & 3 deletions Bug hunting/range_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ leaving 2 bytes allocated but unused/*


/*I have get a very strange problem here, line 17 foor loop, after finishing the process of for loop, the range variable value become
8 to 0, but the value store in different varibale. So I dig into the address arithmatic and find that when allocate memory for count array
8 to 0, but the value store in different variable. So I dig into the address arithmetic and find that when allocate memory for count array
(line 11) exact less than the requirement, the line 19 for loop access to that address(where the range "range" variable value store),
and set it as 0(as we here set count[i] = 0, we also set different value). Also this happened only when we pass a array from the main
function.

If we don't pass the and array from the main function it doesn't happend.
Also one thing I observe it happend when we pass multipy of 4 like 0,4,8,12,16,20.
If we don't pass the and array from the main function it doesn't happened.
Also one thing I observe it happened when we pass multiply of 4 like 0,4,8,12,16,20.
One thing may be

*/
Expand Down
8 changes: 4 additions & 4 deletions C++/Basics/Casting/103_DynamicCasting.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
dynamic cast is actullay for casting from one class to another.
dynamic cast is actually for casting from one class to another.
Base class to Child class = DownCasting
Child class to Base class = UpCasting
But if we manually do DownCasting, it would be Ok, because Child class already have information about Base class
But UpCasting may cause problem, because a function which is unique to Child class may not have in Base class.
Also a Child class instance, which type is "pointer to a Base" class, if we cast it to another Child of Base class
then it might crash the problem as well, because in Casting time don't know what the actual type of that instance.
In dynamic_cast casting will not happend and return "null" in this case.
In dynamic_cast casting will not happened and return "null" in this case.

https:www.youtube.com/watch?v=CiHfz6pTolQ&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=74
https:www.geeksforgeeks.org/dynamic-_cast-in-cpp/
Expand All @@ -22,7 +22,7 @@
#include<iostream>
using namespace std;

// Polymorphic class, becase it has one virtual function.
// Polymorphic class, because it has one virtual function.
class Base{
public:
virtual void print(){
Expand Down Expand Up @@ -54,7 +54,7 @@ int main(){
if(c1){
c1->print();
}else{
cout << "Cust didn't successfull" << endl;
cout << "Cust didn't successful" << endl;
}

}
Expand Down
6 changes: 3 additions & 3 deletions C++/Basics/Lamda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ void printVector(vector<int> v, void(*print)(int)){
int main(){

vector<int> v = {1,2,3,4,5,6,7,8,9,10};
// inline lamda function, which we can also put in a variable
// lamda function always start with [] which called "capture clause"
// inline lambda function, which we can also put in a variable
// lambda function always start with [] which called "capture clause"
printVector(v, [](int val) { cout << val << endl; });

// the capture clause[] also take argument &(pass by ref), =(pass by val) ,
// by which we can access to the outside argument in lamda function.
// by which we can access to the outside argument in lambda function.

}
12 changes: 6 additions & 6 deletions C++/Basics/Templete(Generics).cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// I found templete & Generics are same concept in C++
// Generics implment using templete
// I found template & Generics are same concept in C++
// Generics implement using template
// https://www.geeksforgeeks.org/templates-cpp/
// https://www.geeksforgeeks.org/generics-in-c/
// https://www.youtube.com/watch?v=I-hZkUa9mIs&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=53
Expand All @@ -12,8 +12,8 @@ using namespace std;


// temeplete class
// define templete
// we can also take multiple arguments in templete
// define template
// we can also take multiple arguments in template
template<typename T, typename U>

class Complex{
Expand All @@ -34,8 +34,8 @@ class Complex{
};


// templete function
// define templete
// template function
// define template
template<typename T>
T compare(T o1, T o2){
return (o1 > o2) ? o1 : o2;
Expand Down
2 changes: 1 addition & 1 deletion C++/Basics/Union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace std;


// union used for type punning or aliasing. The largest data member of the union is hold the only memory location.
// rest of the other member used that same location, this actullay for used for holding the same memory with
// rest of the other member used that same location, this actually for used for holding the same memory with
// different types.
union Complex{
int x;
Expand Down
2 changes: 1 addition & 1 deletion C++/Basics/const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using namespace std;

int main(){
// const variable means it value can't be changed,
// also have intialize at decleartion time.
// also have initialize at decleartion time.
const int a = 10;
int b = 12;

Expand Down
2 changes: 1 addition & 1 deletion C++/Basics/enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using namespace std;

// enum only take integer type
// defaule start from 0
// default start from 0
// we can also define integer type
// enum Gender:char{male, female};

Expand Down
4 changes: 2 additions & 2 deletions C++/Basics/mutable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// as constant object can only call constant method of class
// so, to somwhow change any variable inside the const method, we can
// so, to somehow change any variable inside the const method, we can
// marks that variable as mutable.

#include<iostream>
Expand All @@ -19,7 +19,7 @@ class Player{
if(!weight){
weight = 60;
}
cout << "heigh: " << height << " weight: " << weight << endl;
cout << "height: " << height << " weight: " << weight << endl;
}
};

Expand Down
4 changes: 2 additions & 2 deletions C++/Basics/new.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// https : //www.youtube.com/watch?v=NUZdUSqsCs4&list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb&index=39
// "new" always allocate memmory in heap
// "new" always allocate memory in heap

#include<iostream>
using namespace std;
Expand All @@ -15,7 +15,7 @@ class Parent{
int main(){
// allocating single integer in the heap, single integer here is 4 bytes( depends on compiler).
int* n = new int;
// allocating 50 block of interger type contiguous memory in the heap. ( 4 (interger size) * 50 = 200 bytes of memory)
// allocating 50 block of integer type contiguous memory in the heap. ( 4 (integer size) * 50 = 200 bytes of memory)
int* array = new int[50];

// allocating size of Parent class memory in the heap
Expand Down
4 changes: 2 additions & 2 deletions C++/Basics/ranged_based_foorLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ int main(){
cout << var << endl;
}

// we can decelar the array direcly inside the loop
// we can decelar the array directly inside the loop
for(int x : vector<int>{1, 3, 5, 7, 9}){
cout << x << endl;
}

int num[3] = {100, 200, 300};
// normall iterator "int x" will copy the array value every times, so we can just
// normal iterator "int x" will copy the array value every times, so we can just
// reference "int& x" the array values, also make the iterator const doesn't allow us to modify
// the value.
for(const int& x : num){
Expand Down
2 changes: 1 addition & 1 deletion C++/Basics/smart_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Person{
};

int main(){
// unique_ptr are hold unique_position. So, they cann't be copied, or store in another pointer,
// unique_ptr are hold unique_position. So, they can't be copied, or store in another pointer,
// because if one pointer freed that location, another then hold that empty free position,
// try to free again and crashed program
unique_ptr<Person> u_ptr = make_unique<Person>("u_ptr", 24);
Expand Down
6 changes: 3 additions & 3 deletions C++/Basics/static_variable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// https://www.geeksforgeeks.org/static-variables-in-c/
// static variable also initialized 0 by compiler if not explicitly initilized by programmer.
// static variable also initialized 0 by compiler if not explicitly initialized by programmer.


/* Static variable in C++, have life time scope, so it always retain position, not destroyed by any function call or wipe out the
Expand All @@ -16,15 +16,15 @@
#include<iostream>
using namespace std;

// Global static variable, which visiable to all over the file.
// Global static variable, which visible to all over the file.
static int a = 0;

void incrementGlobal(){
++a;
}

int incrementLocal(){
// Local static variable, which visiable to only this function.
// Local static variable, which visible to only this function.
static int b = 0;
return ++b;
}
Expand Down
4 changes: 2 additions & 2 deletions C++/Basics/ternary_operator.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// the ternary operator is alternative of if else condition, also it has some performance benefit
// if we wrote this code as like,

// in here we actully creating an empty string object, then we override the object inside the if else block with new one,
// so it's technically slow, beacuse we first creating an empty string, then destroying it and again override this.
// in here we actually creating an empty string object, then we override the object inside the if else block with new one,
// so it's technically slow, because we first creating an empty string, then destroying it and again override this.
// but, in this case ternary value can do some return value optimization.
// also ternary operator looks cleaner.

Expand Down
2 changes: 1 addition & 1 deletion C++/Container/0002_Vector/0002_reserve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// but we can allocate space in first position like array.
// so the requested space will allocated for the vector.
// no dynamic allocation will happened before the space has consumed.
// increase performace.
// increase performance.

#include<iostream>
#include<vector>
Expand Down
2 changes: 1 addition & 1 deletion C++/Object Oriented Programming/1112. Constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Player{

};

//constructor defintion
//constructor definition
Player::Player(int x, int y){
X = x;
Y = y;
Expand Down
Loading