Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Shuffle String leetcode solution in c++

class Solution {
public:
    string restoreString(string s, vector<int>& indices) {
        string ans=s;
	    for (int i = 0; i < indices.size(); i++)
	    {
		    ans[indices[i]]=s[i];
	    }
	    return ans;
    }
};
Comment

Shuffle String leetcode solution in cpp

class Solution {
public:
    string restoreString(string s, vector<int>& indices) {
        string ans;
        for (int i = 0; i < indices.size(); i++)
        {
            for (int j = 0; j < indices.size(); j++)
            {
                 if (i == indices[j])
                 {
                     ans += s[j];
                 }
            }
        }
        return ans;
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++ detaching threads 
Cpp :: how to find product of a given numbers in c++ 
Cpp :: c++ catch Unhandled exception 
Cpp :: c++ for loop syntax 
Cpp :: 2d array of zeros c++ 
Cpp :: len in cpp 
Cpp :: How to pass a multidimensional array to a function in C and C++ 
Cpp :: cpp vector popback 
Cpp :: erase range vector c++ 
Cpp :: c++ check if number is even or odd 
Cpp :: c++ pointers and arrays 
Cpp :: how to insert in a queue c++ 
Cpp :: c++ length of int 
Cpp :: public method 
Cpp :: c++ last element of array 
Cpp :: C++ switch..case Statement 
Cpp :: remove elements from vector 
Cpp :: create a copy of a vector c++ 
Cpp :: cpp algorithm iota 
Cpp :: c++ how to do a pointer char to take varols from keyboard 
Cpp :: lap trinh file explorer c++ 
Cpp :: how to find second smallest element in an array using single loop 
Cpp :: binary to int c++ bitset 
Cpp :: initalising array c++ 
Cpp :: C++ for vs while loops 
Cpp :: KL/wweiok#L['.[- 
Cpp :: c++ terinary operator 
Cpp :: c++ reverse bits 
Cpp :: cin une énumération 
Cpp :: #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =