Pages

Saturday, April 26, 2025

Vectors in C++

 #include <iostream>

#include <vector>

using namespace std;


int main()

{

    vector<int> vec1(10, -1);

    cout << vec1.size() << "\n";

    

    

    // to access size of invidivual vectors

    

    for(int i=0; i<vec1.size(); i++) {

        cout << vec1[i] << " ";

    }

    

    cout << endl;

    return 0;

}

No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...