Description stringstream is a stream class to operate on strings. It basically implements input/output operations on memory (string) based streams. stringstream can be helpful in different type of […]
Box It! – C++ HackerRank
One thing to note is to convert one of the multipliers to long long in advance so that the result in the middle won’t be […]
Deque-STL – HackerRank
The crux here is that a number must be pushed into the deque on its turn since the bigger ones will be obsolete when they […]
Print Pretty – HackerRank
Three ways to set ioflags: (They are of type ios::fmtflags) All the configurations are global. Example References http://www.cplusplus.com/reference/ios/ios_base/fmtflags/ http://www.cplusplus.com/reference/iomanip/setiosflags/
Variable Sized Arrays – HackerRank
It’s about C++ vector.
3Sum Closest – LeetCode #16
Description Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You […]
序列和 – NowCoder IDE Try Out
Description 题目描述 给出一个正整数N和长度L,找出一段长度大于等于L的连续非负整数,他们的和恰好为N。答案可能有多个,我我们需要找出长度最小的那个。例如 N = 18 L = 2:5 + 6 + 7 = 183 + 4 + 5 + 6 = 18都是满足要求的,但是我们输出更短的 5 6 […]
3Sum – #15 LeetCode
Description Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution […]
Longest Common Prefix – #14 LeetCode
Description Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty […]