CJCoding With Joseph
15free / daySign inCreate account
TitleTopicsAction
185
Sum a Vector (STL)Write a function int sumVector(const vector<int>& nums) that returns the sum of ...
easy○ Not Started
STL Containers
Solve
454
Insert Into a SetA `set<int>` named `s` has already been declared for you. Insert the values 3, 1...
easy○ Not Started
STL ContainersSets
Solve
455
Print a Set in Sorted OrderA `set<int>` named `s` already holds the values 5, 1 and 3. Write a range-based ...
easy○ Not Started
STL ContainersSets
Solve
456
Duplicates Are IgnoredA `set<int>` named `s` has been declared for you. Insert the values 4, 4, 4 and ...
easy○ Not Started
STL ContainersSets
Solve
457
Check Membership with countWrite a function `bool contains(const set<int>& s, int x)` that returns `true` i...
easy○ Not Started
STL ContainersSets
Solve
458
Erase a Value from a SetA `set<int>` named `s` holds 1, 2, 3 and 4, and a loop that prints the set is al...
easy○ Not Started
STL ContainersSets
Solve
459
Set of Strings Sorts AlphabeticallyA `set<string>` named `names` has been declared, and a loop that prints each nam...
easy○ Not Started
STL ContainersSets
Solve
460
Count Unique ValuesWrite a function `int countUnique(const vector<int>& v)` that returns how many d...
easy○ Not Started
STL ContainersSets
Solve
461
Smallest and Largest in a SetA `set<int>` named `s` holds 7, 2, 9 and 4. Print its smallest value and its lar...
easy○ Not Started
STL ContainersSets
Solve
462
multiset Keeps DuplicatesA `multiset<int>` named `ms` has been declared for you. Insert 3, 3 and 1 (three...
easy○ Not Started
STL ContainersSets
Solve
463
unordered_set LookupWrite a function `bool hasWord(const unordered_set<string>& words, const string&...
easy○ Not Started
STL ContainersSets
Solve
478
Push and Look at the FrontA `queue<int>` named `q` has already been created for you. Push the values 10, 2...
easy○ Not Started
STL ContainersQueues
Solve
479
Pop the FrontA `queue<int>` named `q` already holds 10, 20, 30 (10 is at the front). Remove ...
easy○ Not Started
STL ContainersQueues
Solve
480
Drain a QueueA `queue<int>` named `q` already holds 1, 2, 3 (1 is at the front). Write a loo...
easy○ Not Started
STL ContainersQueues
Solve
481
Queue StatusWrite a function `string status(const queue<int>& q)` that returns the string "e...
easy○ Not Started
STL ContainersQueues
Solve
482
Back of the QueueA `queue<int>` named `q` already holds 10, 20, 30 (10 is at the front, 30 is at ...
easy○ Not Started
STL ContainersQueues
Solve
483
Priority Queue Puts Largest on TopA `priority_queue<int>` named `pq` has already been created. Push 5, 1 and 9 (in...
easy○ Not Started
STL ContainersQueues
Solve
484
Min-Heap with greaterA min-heap has already been declared for you: `priority_queue<int, vector<int>, ...
easy○ Not Started
STL ContainersQueues
Solve
485
Serve the Front CustomerWrite a function `void serve(queue<string>& line)` that serves the customer at t...
easy○ Not Started
STL ContainersQueues
Solve
486
Deque Push Both EndsA `deque<int>` named `d` has already been created, and a loop that prints every ...
easy○ Not Started
STL ContainersQueues
Solve
487
Build a Queue from a VectorWrite a function `queue<int> toQueue(const vector<int>& v)` that returns a new `...
easy○ Not Started
STL ContainersQueues
Solve
502
Push and PeekA `stack<int>` named `s` has already been created in main. Push the values 1, 2 ...
easy○ Not Started
STL ContainersStacks
Solve
503
Pop Then PeekA `stack<int>` named `s` already holds 1, 2, 3 (3 is on top). Remove the top ele...
easy○ Not Started
STL ContainersStacks
Solve
504
Drain a StackA `stack<int>` named `s` already holds 1, 2, 3 (3 is on top). Write a loop that ...
easy○ Not Started
STL ContainersStacks
Solve
505
Top or NoneWrite a function `string topOrNone(const stack<int>& s)`. If the stack is empty,...
easy○ Not Started
STL ContainersStacks
Solve
506
Reverse a Word with a StackThe variable `word` holds "hello", and an empty `stack<char>` named `s` and an e...
easy○ Not Started
STL ContainersStacks
Solve
507
Undo History StackA `stack<string>` named `history` already holds three actions pushed in this ord...
easy○ Not Started
STL ContainersStacks
Solve
508
Push All from a VectorWrite a function `void pushAll(stack<int>& s, const vector<int>& v)` that pushes...
easy○ Not Started
STL ContainersStacks
Solve
509
Sum the Top TwoWrite a function `int sumTopTwo(stack<int> s)` that returns the sum of the two e...
easy○ Not Started
STL ContainersStacks
Solve
510
Size After Mixed OperationsAn empty `stack<int>` named `s` is already declared. Perform these six operation...
easy○ Not Started
STL ContainersStacks
Solve
511
Balanced Round BracketsWrite a function `bool balanced(const string& s)` that returns true when every `...
easy○ Not Started
STL ContainersStacks
Solve
526
Fill a std::array in a LoopAn `array<int, 5>` named `a` has already been declared for you, and two loops ar...
easy○ Not Started
STL Containersstd::array
Solve
527
Size of a std::arrayAn `array<int, 4>` named `a` has been created with the values {10, 20, 30, 40}. ...
easy○ Not Started
STL Containersstd::array
Solve
528
Sum a std::arrayWrite a function `int sumArray(const array<int, 5>& a)` that returns the sum of ...
easy○ Not Started
STL Containersstd::array
Solve
529
fill With One ValueAn array `a` of four ints has been declared but not initialized, and a printing ...
easy○ Not Started
STL Containersstd::array
Solve
530
front and backAn `array<int, 3>` named `a` has been created with the values {3, 5, 9}. Print ...
easy○ Not Started
STL Containersstd::array
Solve
531
Bounds-Checked at()An `array<int, 4>` named `a` holds {1, 2, 3, 4} and an `int index` is set to 10....
easy○ Not Started
STL Containersstd::array
Solve
532
Largest in a std::arrayWrite a function `int maxOf(const array<int, 6>& a)` that returns the largest of...
easy○ Not Started
STL Containersstd::array
Solve
533
Array of Strings With IndexAn `array<string, 3>` named `days` has been created with the values {"Mon", "Tue...
easy○ Not Started
STL Containersstd::array
Solve
534
Copying a std::arrayThe code already creates `array<int, 3> a = {1, 2, 3};`, copies it with `array<i...
easy○ Not Started
STL Containersstd::array
Solve
535
Sort a std::arrayAn `array<int, 4>` named `a` holds {5, 1, 8, 2}, and a printing loop is already ...
easy○ Not Started
STL Containersstd::array
Solve
550
Print with an Iterator LoopA vector `v` has already been created with the values {1, 2, 3}. Write a for loo...
easy○ Not Started
STL ContainersIterators
Solve
551
Dereference and AdvanceA vector `v` has already been created with the values {10, 20, 30}. Complete the...
easy○ Not Started
STL ContainersIterators
Solve
552
Reverse IterationA vector `v` has already been created with the values {1, 2, 3}. Write a loop fr...
easy○ Not Started
STL ContainersIterators
Solve
553
Modify Through an IteratorA vector `v` has already been created with the values {1, 2, 3}, and an iterator...
easy○ Not Started
STL ContainersIterators
Solve
554
const_iterator SumWrite a function `int sumConst(const vector<int>& v)` that adds up every element...
easy○ Not Started
STL ContainersIterators
Solve
555
Distance Between IteratorsA vector `v` has already been created with the values {5, 6, 7, 8}. Use `std::di...
easy○ Not Started
STL ContainersIterators
Solve
556
find Returns an IteratorA vector `v` has already been created with the values {10, 20, 30, 40} and an in...
easy○ Not Started
STL ContainersIterators
Solve
557
next and prevA vector `v` has already been created with the values {1, 2, 3, 4, 5}. Complete ...
easy○ Not Started
STL ContainersIterators
Solve
558
Erase via IteratorA vector `v` has already been created with the values {1, 2, 3, 4}. Erase the el...
easy○ Not Started
STL ContainersIterators
Solve
559
Iterating a std::setA set `s` has already been created from the values {6, 2, 4}. Write an iterator ...
easy○ Not Started
STL ContainersIterators
Solve
186
Sort a Vector with std::sortUse std::sort to sort a vector of ints in ascending order. Write a function void...
medium○ Not Started
STL Containers
Solve
187
Count Occurrences with std::mapWrite a function int countOccurrences(const vector<int>& nums, int target) that ...
medium○ Not Started
STL Containers
Solve
464
Unique Numbers from InputWrite a program that reads an integer N from standard input followed by N intege...
medium○ Not Started
STL ContainersSets
Solve
465
Count Newly Inserted ValuesWrite a function `int insertAll(set<int>& s, const vector<int>& v)` that inserts...
medium○ Not Started
STL ContainersSets
Solve
466
Common Elements of Two SetsWrite a function `vector<int> commonElements(const set<int>& a, const set<int>& ...
medium○ Not Started
STL ContainersSets
Solve
467
Elements Only in the First SetWrite a function `set<int> difference(const set<int>& a, const set<int>& b)` tha...
medium○ Not Started
STL ContainersSets
Solve
468
Remove Duplicate WordsWrite a program that reads words from standard input until the input ends (use `...
medium○ Not Started
STL ContainersSets
Solve
469
Erase Evens While IteratingWrite a function `void removeEvens(set<int>& s)` that erases every even value fr...
medium○ Not Started
STL ContainersSets
Solve
470
First Repeated NumberKeep a `set<int>` of the values seen so far. Write a function `int firstRepeat(...
medium○ Not Started
STL ContainersSets
Solve
471
First Value At Least XWrite a function `int firstAtLeast(const set<int>& s, int x)` that returns the s...
medium○ Not Started
STL ContainersSets
Solve
472
Tally a multisetA `multiset<int>` named `ms` already holds the values 2, 5, 2, 8, 5, 2. Print ea...
medium○ Not Started
STL ContainersSets
Solve
473
Are All Elements Unique?Write a function `bool allUnique(const vector<int>& v)` that returns `true` if n...
medium○ Not Started
STL ContainersSets
Solve
488
Read Numbers Into a QueueWrite a program that reads an integer N from standard input, followed by N integ...
medium○ Not Started
STL ContainersQueues
Solve
489
Sum a Queue Without Emptying ItWrite a function `int sumQueue(queue<int> q)` that returns the sum of every elem...
medium○ Not Started
STL ContainersQueues
Solve
490
Ticket Line SimulationSimulate a ticket line with a `queue<string>`. Read commands from standard input...
medium○ Not Started
STL ContainersQueues
Solve
491
Top K LargestWrite a function `vector<int> topK(const vector<int>& v, int k)` that returns th...
medium○ Not Started
STL ContainersQueues
Solve
492
Reverse a Queue Using a StackWrite a function `void reverseQueue(queue<int>& q)` that reverses the order of t...
medium○ Not Started
STL ContainersQueues
Solve
493
Print Heap Values DescendingA `priority_queue<int>` named `pq` has already been created and filled with 4, 9...
medium○ Not Started
STL ContainersQueues
Solve
494
Priority Queue of PairsA `priority_queue<pair<int, string>> tasks;` has already been declared. Each pai...
medium○ Not Started
STL ContainersQueues
Solve
495
Interleave Two QueuesWrite a function `queue<int> interleave(queue<int> a, queue<int> b)` that return...
medium○ Not Started
STL ContainersQueues
Solve
496
Keep Only the Last NWrite a function `deque<int> keepLast(const vector<int>& v, int n)` that returns...
medium○ Not Started
STL ContainersQueues
Solve
497
Kth Smallest with a Min-HeapWrite a function `int kthSmallest(const vector<int>& v, int k)` that returns the...
medium○ Not Started
STL ContainersQueues
Solve
512
Reverse Numbers from InputWrite a program that reads integers from standard input until the input ends, pu...
medium○ Not Started
STL ContainersStacks
Solve
513
Balanced Brackets Three KindsWrite a function `bool isBalanced(const string& s)` that uses a `stack<char>` to...
medium○ Not Started
STL ContainersStacks
Solve
514
Evaluate PostfixWrite a function `int evalPostfix(const vector<string>& tokens)` that uses a `st...
medium○ Not Started
STL ContainersStacks
Solve
515
Decimal to Binary with a StackWrite a function `string toBinary(int n)` that returns the binary representation...
medium○ Not Started
STL ContainersStacks
Solve
516
Sum a Stack CopyWrite a function `int sumStack(stack<int> s)` that returns the sum of every elem...
medium○ Not Started
STL ContainersStacks
Solve
517
Undo Text EditorWrite a program that simulates a tiny text editor with undo. Read commands from ...
medium○ Not Started
STL ContainersStacks
Solve
518
Next Greater ElementWrite a function `vector<int> nextGreater(const vector<int>& v)` that returns a ...
medium○ Not Started
STL ContainersStacks
Solve
519
Stack to Vector Bottom FirstWrite a function `vector<int> bottomFirst(stack<int> s)` that returns the stack'...
medium○ Not Started
STL ContainersStacks
Solve
520
Remove Adjacent DuplicatesWrite a function `string removeAdjacent(const string& s)` that uses a `stack<cha...
medium○ Not Started
STL ContainersStacks
Solve
521
Palindrome Check with a StackWrite a function `bool isPalindrome(const string& s)` that uses a `stack<char>` ...
medium○ Not Started
STL ContainersStacks
Solve
536
Five Numbers from InputWrite a program that reads exactly five integers from standard input (separated ...
medium○ Not Started
STL Containersstd::array
Solve
537
Reverse a std::array In PlaceWrite a function `void reverseArray(array<int, 5>& a)` that reverses the order o...
medium○ Not Started
STL Containersstd::array
Solve
538
Count Even ValuesWrite a function `int countEven(const array<int, 8>& a)` that returns how many o...
medium○ Not Started
STL Containersstd::array
Solve
539
Sum Any Size (Template Parameter)Write a function template `template <size_t N> int sumAny(const array<int, N>& a...
medium○ Not Started
STL Containersstd::array
Solve
540
3x3 Grid with Nested std::arrayA variable `grid` of type `array<array<int, 3>, 3>` has been declared for you. ...
medium○ Not Started
STL Containersstd::array
Solve
541
Index of a ValueWrite a function `int indexOf(const array<int, 6>& a, int x)` that returns the i...
medium○ Not Started
STL Containersstd::array
Solve
542
Rotate Left by OneWrite a function `void rotateLeft(array<int, 5>& a)` that moves every element on...
medium○ Not Started
STL Containersstd::array
Solve
543
Swap Two ArraysThe code already creates `array<int, 3> a = {1, 2, 3};` and `array<int, 3> b = {...
medium○ Not Started
STL Containersstd::array
Solve
544
Weekly Temperature ReportAn `array<double, 7>` named `temps` holds one temperature per day of the week: {...
medium○ Not Started
STL Containersstd::array
Solve
545
Compare Two ArraysWrite a function `bool sameContents(const array<int, 4>& a, const array<int, 4>&...
medium○ Not Started
STL Containersstd::array
Solve
560
Sum Between Two IteratorsWrite a function `int sumRange(vector<int>::iterator first, vector<int>::iterato...
medium○ Not Started
STL ContainersIterators
Solve
561
Erase Every Matching ValueWrite a function `void removeValue(vector<int>& v, int x)` that removes every el...
medium○ Not Started
STL ContainersIterators
Solve
562
Insert Before a ValueWrite a function `void insertBefore(vector<int>& v, int target, int val)` that: ...
medium○ Not Started
STL ContainersIterators
Solve
563
Second Largest with Iterator ArithmeticWrite a function `int secondLargest(vector<int> v)` that returns the second-larg...
medium○ Not Started
STL ContainersIterators
Solve
564
Print Every Other ElementWrite a function `void printEveryOther(const vector<int>& v)` that prints the el...
medium○ Not Started
STL ContainersIterators
Solve
565
Reverse a String with Reverse IteratorsWrite a function `string reversed(const string& s)` that returns a new string co...
medium○ Not Started
STL ContainersIterators
Solve
566
Index of the MaximumWrite a function `int indexOfMax(const vector<int>& v)` that returns the 0-based...
medium○ Not Started
STL ContainersIterators
Solve
567
Iterate a Map with IteratorsA `map<string, int>` named `stock` has already been created with `apple` mapped ...
medium○ Not Started
STL ContainersIterators
Solve
568
Reverse Input with Reverse IteratorsWrite a program that reads whole numbers from standard input until there is no m...
medium○ Not Started
STL ContainersIterators
Solve
569
First Half by Iterator RangeWrite a function `vector<int> firstHalf(const vector<int>& v)` that returns a ne...
medium○ Not Started
STL ContainersIterators
Solve
474
Unique Word TrackerBuild a class `UniqueWords` that stores the distinct words in a `set<string>`. I...
hard○ Not Started
STL ContainersSets
Solve
475
Number Set Range QueriesBuild a class `NumberSet` that stores distinct integers in a `set<int>` and answ...
hard○ Not Started
STL ContainersSets
Solve
476
Set Algebra From InputRead two lines from standard input. The first line holds the integers of set A a...
hard○ Not Started
STL ContainersSets
Solve
477
Inventory with multisetBuild a class `Inventory` that stores item names in a `multiset<string>`, so the...
hard○ Not Started
STL ContainersSets
Solve
498
Printer Job SchedulerBuild a class `PrintQueue` that serves print jobs first-come, first-served, stor...
hard○ Not Started
STL ContainersQueues
Solve
499
Emergency Room TriageBuild a class `Triage` that decides which emergency-room patient is seen next, u...
hard○ Not Started
STL ContainersQueues
Solve
500
Round-Robin SchedulerWrite a round-robin CPU scheduler. Input: the first line holds the time quantum ...
hard○ Not Started
STL ContainersQueues
Solve
501
Josephus Elimination Ordern people numbered 1 to n stand in a circle. Counting from person 1, every k-th p...
hard○ Not Started
STL ContainersQueues
Solve
522
Min StackBuild a class `MinStack` that behaves like a normal stack of ints but can also r...
hard○ Not Started
STL ContainersStacks
Solve
523
Infix to PostfixWrite a function `string toPostfix(const string& expr)` that converts an infix a...
hard○ Not Started
STL ContainersStacks
Solve
524
Browser HistoryBuild a class `BrowserHistory` that models the back and forward buttons of a web...
hard○ Not Started
STL ContainersStacks
Solve
525
Queue Made of Two StacksBuild a class `StackQueue` that behaves like a first-in first-out queue of ints ...
hard○ Not Started
STL ContainersStacks
Solve
546
Fixed-Size Ring BufferBuild a class `RingBuffer` that stores its values in an `array<int, 4>` (capacit...
hard○ Not Started
STL Containersstd::array
Solve
547
Tic-Tac-Toe WinnerA tic-tac-toe board is an `array<array<char, 3>, 3>`: `b[row][col]` is `'X'`, `'...
hard○ Not Started
STL Containersstd::array
Solve
548
2x2 Matrix MultiplyA 2x2 matrix is an `array<array<int, 2>, 2>`, where `m[r][c]` is the value in ro...
hard○ Not Started
STL Containersstd::array
Solve
549
Digit Histogram from InputWrite a program that reads non-negative integers from standard input until the i...
hard○ Not Started
STL Containersstd::array
Solve
570
Countdown Range ClassCreate a class `Countdown` with: 1. A constructor `Countdown(int n)` that stores...
hard○ Not Started
STL ContainersIterators
Solve
571
Remove Duplicates Keeping OrderWrite a function `void dedupe(vector<int>& v)` that modifies `v` in place so tha...
hard○ Not Started
STL ContainersIterators
Solve
572
Merge Two Sorted VectorsWrite a function `vector<int> mergeSorted(const vector<int>& a, const vector<int...
hard○ Not Started
STL ContainersIterators
Solve
573
Linked List with IteratorCreate a class `IntList`, a singly linked list of ints, with: 1. A private neste...
hard○ Not Started
STL ContainersIterators
Solve