Symantec Interview Question for Senior Software Development Engineers


Team: DS
Country: India
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

{{
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <regex>
using namespace std;

int main ()
{

string result;
string string_to_split ="L\"\\?\\UNC\\10.1.3.23\TOKEN$\\C\\FileDrive\\Testcase.doc";
std::regex rgx("TOKEN\\$");
std::sregex_token_iterator iter(string_to_split.begin(),
string_to_split.end(),
rgx,
-1);
std::sregex_token_iterator end;
for ( ; iter != end; ++iter)
{
result += *iter;
}
std::cout << result << '\n';
return 0;
}


}}

- Rajarathinam Antony December 09, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

With C++11 regex.....

- Rajarathinam Antony December 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Forgot the token after "TOKEN$".....let me update and post again

- Rajarathinam Antony December 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <boost/regex.hpp>
#include <string>
#include <iostream>

int main()
{
std::string s ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x46456\\C\\FileDrive\\Testcase.doc";
boost::regex expr{"(\\\\)0x(\\d)+"};
std::string fmt{""};
std::cout << boost::regex_replace(s, expr, fmt) << '\n';
}

- Rajarathinam Antony December 09, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <boost/regex.hpp>
#include <string>
#include <iostream>

int main()
{
std::string s ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x46456\\C\\FileDrive\\Testcase.doc";
boost::regex expr{"(\\\\)0x(\\d)+"};
std::string fmt{""};
std::cout << boost::regex_replace(s, expr, fmt) << '\n';
}

- Rajarathinam Antony December 09, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

#include <iostream>
#include <string>

using namespace std;

int main()
{
cout << "Hello world!" << endl;

string ss ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x432567\\C\\FileDrive\\Testcase.doc";

std::cout << ss<< "\n";
std::string::size_type n = ss.find("TOKEN$");

std::string::size_type first = ss.find("\\",n);
std::string::size_type last = ss.find("\\",first+1);

if (n == std::string::npos) {
std::cout << "not found\n";
} else {
ss.replace(first,(last-first),"");
std::cout << "found: " << ss << '\n';
}

return 0;
}

- puru December 11, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{
string ss ="L\"\\?\\UNC\\10.1.3.23\\TOKEN$\\0x432567\\C\\FileDrive\\Testcase.doc";

std::cout << ss<< "\n";
std::string::size_type n = ss.find("TOKEN$");

if (n == std::string::npos) {
std::cout << "not found\n";
} else {

std::string::size_type first = ss.find("\\",n);
std::string::size_type last = ss.find("\\",first+1);

ss.replace(first,(last-first),"");
std::cout << "found: " << ss << '\n';
}

return 0;
}

- puru.hirave December 11, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More