Week 1, DSA 02/04, array

 PPT:- https://projects.100xdevs.com/tracks/dsa/dsa1

DSA stands for data Structure and Algorithms.

Data Structures:  means the way some data is stored for example: we can store data as lists or in a stack or as a tree, All of these are examples of data structures,


Algorithms is a set of steps you need to follow to solve some problem. Either the set fo steps is known {example, sorting, DFS etc} or you derive the set of steps using first principles and logical thinking


CP stands for Competitive Programing. it is a sport where competitors solve DSA ICPC IOI code jam local contests


Array:  Collection of elements of some (any) type is called an array /list


int f(int x, vector<int>& nums) {

//count of all the pairs (i,x) where A[i] = A[x] and i != x and A is the prefix till x

// A =  [nums[0], nums[1], ......, nums[x]]

int count = 0;

for(int i = 0 ; i< ; i++) {

if (nums[i] = nums[x]) {

count +=1;

}

}

return count;

}


int numIdenticalParis(vector<int>& nums) {

//f(x) will compute all the good pairs whre x is the RHS

//for all good pairs we need to compute f(x) for every possible value of x

int n = nums.size();


int ans = 0;

for (int x =0; x<n; x++) {

ans += f(x, nums);

}

returnt ans;

}

};

Comments

Popular posts from this blog

CyberSecurity

VERTICAL SCALING 💋

prisma using in project idx 13.3