#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
string change(int num, int len)
{
    string temp;
    
    while(num > 0)
    {
        temp = to_string(num % 2+ temp;
        num /= 2;
    }
    
    while(len != temp.size())
    {
        temp = "0" + temp;
    }
    
    return temp;
}
 
vector<string> solution(int n, vector<int> arr1, vector<int> arr2) 
{
    vector<string> answer;
    vector<string> set1;
    vector<string> set2;
 
    for(int i = 0; i < arr1.size(); i++)
    {
        if(arr1[i] != 0)
        {
            set1.push_back(change(arr1[i], n));   
        }
        else
        {
            string temp;
            for(int j = 1; j <= n; j++)
            {
                temp += "0";
            }
            
            set1.push_back(temp);
        }
        
        if(arr2[i] != 0)
        {
            set2.push_back(change(arr2[i], n));   
        }
        else
        {
            string temp;
            for(int j = 1; j <= n; j++)
            {
                temp += "0";
            }
            
            set2.push_back(temp);
        }
    }
    
    for(int i = 0; i < set1.size(); i++)
    {
        string temp;
        
        for(int j = 0; j < set1[i].size(); j++)
        {
            if(set1[i][j] == '1' || set2[i][j] == '1')
            {
                temp += "#";
            }
            else
            {
                temp += " ";
            }
        }
        
        answer.push_back(temp);
    }
    
    return answer;
}
cs

+ Recent posts