noknow.dev
Sign inSign up
Course overview
C++ Fundamentals
0 / 39 lessons0%

Getting Started

  • Hello, World!
  • Variables and Data Types
  • Arithmetic and Operators
  • Working with std::string
  • Type Conversion and Casting

Control Flow

  • if / else if / else
  • switch / case
  • while and do-while Loops
  • for Loops
  • break, continue, and Finding Primes

Functions

  • Writing Functions
  • Pass by Value vs. Pass by Reference
  • Overloading and Default Parameters
  • Recursion

Arrays and Strings

  • C-style Arrays
  • std::vector — Dynamic Arrays
  • std::string Deep Dive
  • 2D Arrays and Matrices

Pointers and Memory

  • Memory Addresses and Pointers
  • Dynamic Memory: new and delete
  • References vs Pointers

Object-Oriented Programming

  • Classes and Objects
  • Constructors and Destructors
  • Inheritance
  • Virtual Functions and Polymorphism
  • Operator Overloading

The Standard Template Library

  • std::vector in Depth
  • std::map and std::unordered_map
  • std::set and Sorted Unique Collections
  • STL Algorithms

Templates and Generic Programming

  • Function Templates
  • Class Templates

Modern C++ (C++11/14/17)

  • auto and Range-based for
  • Lambda Functions
  • Smart Pointers
  • Move Semantics

Error Handling and Exceptions

  • try / catch / throw
  • Custom Exception Classes
  • RAII and Resource Management

std::vector in Depth

0m 00s

The Workhorse Container

#include <vector>

vector<int> v;
v.push_back(10);   // append
v.push_back(20);
v.push_back(30);

v.size()           // 3
v.front()          // 10
v.back()           // 30
v.pop_back()       // removes 30

v.insert(v.begin()+1, 15);  // insert at position
v.erase(v.begin());          // remove first element
v.clear();

Initializations

vector<int> a = {1,2,3,4,5};
vector<int> b(5, 0);           // five zeros
vector<int> c(a.begin(), a.begin()+3);  // {1,2,3}

Your Task

Write removeDuplicates(vector<int> v) that returns a new vector with duplicates removed, preserving order of first occurrence.
Example: {1,2,2,3,1,4} → {1,2,3,4}

Back
cppCtrl+Enter to run
Output

Click "Run" to execute your code.