Leetcode Online Judge Does Not Support Boost Library for C++ Solutions


I am doing a C++ coding exercise, as usual…. And to split a string in C++, the best/easy way is to use the boost library… However, this is not supported on leetcode online judge…

cpp-and-boost-leetcode-online-judge Leetcode Online Judge Does Not Support Boost Library for C++ Solutions c / c++ leetcode online judge online judge string timus

cpp-and-boost-leetcode-online-judge

C++ without boost library, is a bit hard to learn and use.

cpp-hard-to-learn Leetcode Online Judge Does Not Support Boost Library for C++ Solutions c / c++ leetcode online judge online judge string timus

cpp-hard-to-learn

How to Split a String by Delimiter in C++ using Boost Library?

Take this for example, you can easily use boost::split to split a string into vector of string by a set of delimiters, like this:

1
2
3
#include <boost/algorithm/string.hpp>
vector<string> str;
boost::split(str, "string to , split", boost::is_any_of(" ,"));
#include <boost/algorithm/string.hpp>
vector<string> str;
boost::split(str, "string to , split", boost::is_any_of(" ,"));

This is straightforward and easy to use, similar to other modern programming languages. I hope the boost library can be used by the leetcode and also other online judges e.g. Timus. As it brings conveniences and avoids re-inventing the wheel. It allows us to focus on solving the puzzles. However, this can be disabled for coding exercises related to e.g. implementing the string split function.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
328 words
Last Post: How to Check Any String is Palindrome from Its Permutation?
Next Post: C++ Coding Exercise - Subdomain Visit Count

The Permanent URL is: Leetcode Online Judge Does Not Support Boost Library for C++ Solutions

Leave a Reply