Search
 
SCRIPT & CODE EXAMPLE
 

CPP

2160. Minimum Sum of Four Digit Number After Splitting Digits leetcode solution in c++

class Solution {
public:
    int minimumSum(int num) {
        string s = to_string(num);
	    sort(s.begin(), s.end());
	    string new1, new2;
	    for (int i = 0; i < s.length(); i++)
	     {
		     if (i % 2 == 0)
			     new1 += s[i];
		     else
			     new2 += s[i];
	     }
	     return stoi(new1) + stoi(new2);
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: inverse elment of array c++ 
Cpp :: c++ union set q5 
Cpp :: convert c++ code to exe 
Cpp :: attack on titan junior high list of episodes 
Cpp :: lambda - print-out array and add comment 
Cpp :: how to use and in c++ 
Cpp :: how can I convert each and every element of string push into set in c++? 
Cpp :: icon on win32 button 
Cpp :: Processing a string- CodeChef Solution in CPP 
Cpp :: converting a for loop to a while loop C++ 
Cpp :: multiply two arbitrary integers a and b (a greater than b) 
Cpp :: irremoteesp8266 example 
Cpp :: how to call subclass override method in c++ 
Cpp :: if c++ 
Cpp :: c++ multi-dimensional arrays 
Cpp :: int to string Using to_string method 
Cpp :: how to include a library in arduino 
Cpp :: Find first and last digit of int 
Cpp :: run with cpp version 
Cpp :: cout<<"helloworld"<<endl problem 
C :: reset style matplotlib 
C :: get file extension from base64 string 
C :: find maximum number between 3 numbers in c 
C :: c code to python code converter online 
C :: types of instruction and there meaning in c 
C :: reattach screen linux 
C :: block a website on mac 
C :: c assign pointer to struct 
C :: write array of char to file in c 
C :: c modify char array 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =