week2 DSA 05/04, prefix, frequency Array
problem statement: https://leetcode.com/problems/find-the-highest-altitude/description/ //highest altituade class Solutation { public: int largestAltitued (vecotr <int> & gain ) { int n = gani.size(); vector<int>alt(int,0); for(int i = 1; i<= n; i++;) { alt[i] = alt [i-1] + gain[i-1]; } int max_el = *max_elemenet(alt.begin(), alt.end()); reutrn max_el; } }; **normal way of for loops to count frequency** #include <iostream> #include <string> using namespace std; int main() { string str = "hello"; int freq[26] = {0}; // Array to store frequency of each letter // Calculate frequency of each character for (char c : str) { freq[c - 'a']++; // Increment the count f...