[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-572024-105":3,"detail-sidebar-cat-1-en-105":81,"doc-detail-572024-en":126},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","c-stl-cheatsheet-version-100-competitive-programming-and-technical-interview-essentials","C++ STL Cheatsheet-Version 1.0.0 - Competitive Programming and Technical Interview Essentials","","C++ STL cheatsheet covering core containers, algorithms, and utilities with practical operation lists and typical time complexities. Containers include vector, set, map, unordered_set, unordered_map, stack, queue, and priority_queue, with notes on underlying implementations such as dynamic arrays, balanced binary search trees, and hash tables. Algorithms cover sort, binary_search, lower_bound/upper_bound, max/min element, while utilities summarize pair, tuple, swap, reverse, and next/previous permutation for interview-ready reference.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/general/","General",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/c-stl-cheatsheet-version-100-competitive-programming-and-technical-interview-essentials/572024/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/c-stl-cheatsheet-version-100-competitive-programming-and-technical-interview-essentials/572024.png","ImageObject",442,249,{"name":42,"@type":43},"Taylor Morgan","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",5,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What are the main time complexities for common std::vector operations?","Question",{"text":63,"@type":64},"Access is O(1). Insert/delete at the end is O(1) amortized, while insert/delete elsewhere is O(n). pop_back and clear are O(1) and O(n) respectively.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do std::set and std::map differ in their performance characteristics?",{"text":68,"@type":64},"Both provide insert, delete, and search in O(log n). They are implemented as balanced binary search trees (Red-Black Tree), and map operations are performed by key.",{"name":70,"@type":61,"acceptedAnswer":71},"When should std::unordered_set and std::unordered_map be used instead of ordered containers?",{"text":72,"@type":64},"They offer average O(1) insert/delete/search with worst-case O(n). They are implemented as hash tables, trading guaranteed ordering for hash-based performance.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},572024,1792208494,{"code":4,"msg":82,"data":83},"success",[84,89,94,99,104,109,114,119,123],{"id":85,"doc_module":22,"doc_module_name":25,"category_name":86,"show_sort_weight":87,"slug":88},11,"Presentations",90,"presentations",{"id":90,"doc_module":22,"doc_module_name":25,"category_name":91,"show_sort_weight":92,"slug":93},12,"Resumes",80,"resumes",{"id":95,"doc_module":22,"doc_module_name":25,"category_name":96,"show_sort_weight":97,"slug":98},14,"Invoices",70,"invoices",{"id":100,"doc_module":22,"doc_module_name":25,"category_name":101,"show_sort_weight":102,"slug":103},15,"Posters",60,"posters",{"id":105,"doc_module":22,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},16,"Social Media",50,"social-media",{"id":110,"doc_module":22,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},17,"Forms",40,"forms",{"id":115,"doc_module":22,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},18,"Letters",30,"letters",{"id":120,"doc_module":22,"doc_module_name":25,"category_name":121,"show_sort_weight":55,"slug":122},21,"Paper Templates","papers-templates",{"id":124,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":4,"slug":125},158,"general-158",{"code":4,"msg":82,"data":127},{"doc_id":79,"user_id":128,"nickname":42,"user_avatar":129,"doc_module":22,"category_id":124,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":22,"language":135,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":12,"update_tm":139,"read_time":4},1099523885336,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","C++ STL Cheatsheet-Version 1.0.0  \nEssentials for Competitive Programming and Technical Interviews By Habibur Rahman | ML Developer, Ex-Software Engineer February 4, 2024  \nContainers   \nVector (vector)  \n• Operations: Access (O(1)), Insert/Delete at end (O(1) amortized), Insert/Delete elsewhere (O(n)) .  \n• Note: vector is implemented as a dynamic array.  \n\\#include \u003Cvector>  \nstd::vector\u003Cint> vec ; // Declaration  \nvec .push_back (10); // Insert at the end - Amortized `O(1) ` vec .size (); // Get the number of elements - `O(1) `  \nvec .insert (vec .begin() + i , 20); // Insert at index i (0-based) - `O(n) ` vec .erase (vec .begin() + i); // Remove at index i (0-based) - `O(n) ` vec .pop_back (); // Remove the last element - `O(1) `  \nvec .clear (); // Remove all elements - `O(n) `  \nSet (set)  \n• Operations: Insert/Delete/Search (O(log n)) .  \n• Note: set is implemented as a balanced binary search tree (Red-Black Tree) .  \n\\#include \u003Cset>  \nstd::set\u003Cint> s ;  \ns .insert (1); // Insert an element - `O(log n) ` s .find (1); // Find an element - `O(log n) ` s .erase (1); // Remove an element - `O(log n) ` s .clear (); // Remove all elements - `O(n) `  \ns .size (); // Get the number of elements - `O(1) `  \nMap (map)  \n• Operations: Insert/Delete/Search by key (O(log n)) .  \n• Note: map is implemented as a balanced binary search tree (Red-Black Tree) .  \n\\#include \u003Cmap>  \nstd::map\u003Cint , int> m;  \nm [1] = 2 ; // Insert or update a key-value pair - `O(log n) ` m .emplace (1 , 2); // Insert a key-value pair - `O(log n) `  \nm .find (1); // Find an element by key - `O(log n) ` m .erase (1); // Remove an element by key - `O(log n) ` m .clear (); // Remove all elements - `O(n) `  \nm .size (); // Get the number of elements - `O(1) `  \nUnordered Set (unordered_set)  \n• Operations: Insert/Delete/Search (Average: O(1), Worst: O(n)) .  \n• Note: unordered_set is implemented as a hash table.  \n\\#include \u003Cunordered_set>  \nstd::unordered_set\u003Cint> us ;  \nus .insert (1); // Insert an element - `Average: O(1) ` , Worst: `O(n) ` us .find (1); // Find an element - `Average: O(1) ` , Worst: `O(n) ` us .erase (1); // Remove an element - `Average: O(1) ` , Worst: `O(n) ` us .clear (); // Remove all elements - `O(n) `  \nus .size (); // Get the number of elements - `O(1) `  \nUnordered Map (unordered_map)  \n• Operations: Insert/Delete/Search by key (Average: O(1), Worst: O(n)) .  \n• Note: unordered_map is implemented as a hash table.  \n\\#include \u003Cunordered_map>  \nstd::unordered_map\u003Cint , int> um;  \num [1] = 2 ; // Insert or update a key-value pair-`Average: O(1) ` , Worst: `O(n) ` um .emplace (1 , 2); // Insert a key-value pair - `Average: O(1) ` , Worst: `O(n) ` um .find (1); // Find an element by key - `Average: O(1) ` , Worst: `O(n) `  \num .erase (1); // Remove an element by key - `Average: O(1) ` , Worst: `O(n) ` um .clear (); // Remove all elements - `O(n) `  \num .size (); // Get the number of elements - `O(1) `  \nStack (stack)  \n• Operations: Push/Pop/Top (O(1)) .  \n• Note: stack is implemented as a deque (double-ended queue) .  \n\\#include \u003Cstack>  \nstd::stack\u003Cint> st ;  \nst .push (10); // Push an element - `O(1) ` st .pop(); // Pop an element - `O(1) ` [st](st.top)[.](st.top)[top](st.top)(); // Get the top element - `O(1)`  \nst .size (); // Get the number of elements - `O(1) ` st .empty(); // Check if the stack is empty - `O(1) ` st .clear (); // Remove all elements - `O(n) `  \nQueue (queue)  \n• Operations: Enqueue/Dequeue/Front (O(1)) .  \n• Note: queue is implemented as a deque (double-ended queue) .  \n\\#include \u003Cqueue> std::queue\u003Cint> q;  \nq.push (10); // Enqueue an element - `O(1) ` q.pop(); // Dequeue an element - `O(1) `  \nq.front (); // Get the front element - `O(1) `  \nq.size (); // Get the number of elements - `O(1) ` q.empty(); // Check if the queue is empty - `O(1) ` q.clear (); // Remove all elements - `O(n) `  \nPriority Queue (priority_queue)  \n• Operations: Insert/Delete Max (O(log n)), Get Max (O(1)) .  \n• Note: priority_queue is imple","cbCaiq28FJ95KSTN","https://ap.wps.com/l/cbCaiq28FJ95KSTN","pdf",239930,"English","# Containers\n## Vector (vector)\n## Set (set)\n## Map (map)\n## Unordered Set (unordered_set)\n## Unordered Map (unordered_map)\n## Stack (stack)\n## Queue (queue)\n## Priority Queue (priority_queue)\n# Algorithms\n## Sort\n## Binary Search (binary_search)\n## Lower Bound and Upper Bound\n## Max Element and Min Element\n# Utilities\n## Pair (pair)\n## Tuple (tuple)\n## Swap\n## Reverse\n## Next Permutation and Previous Permutation","[{\"question\":\"What are the main time complexities for common std::vector operations?\",\"answer\":\"Access is O(1). Insert/delete at the end is O(1) amortized, while insert/delete elsewhere is O(n). pop_back and clear are O(1) and O(n) respectively.\"},{\"question\":\"How do std::set and std::map differ in their performance characteristics?\",\"answer\":\"Both provide insert, delete, and search in O(log n). They are implemented as balanced binary search trees (Red-Black Tree), and map operations are performed by key.\"},{\"question\":\"When should std::unordered_set and std::unordered_map be used instead of ordered containers?\",\"answer\":\"They offer average O(1) insert/delete/search with worst-case O(n). They are implemented as hash tables, trading guaranteed ordering for hash-based performance.\"}]","C++ STL Cheatsheet-Version 1.0.0 - Competitive Programming and Technical Interview Essentials | PDF",1791925096]