#### Category : dsa

The question is like: strong text Problem Statement: Minimum Count Problem Level: MEDIUM Problem Description: Given an integer N, find and return the count of minimum numbers required to represent N as a sum of squares. That is, if N is 4, then we can represent it as : {1^2 + 1^2 + 1^2 + ..

I’m new in binary tree, i want to traverse the 2 node in the binary tree but the output result into a random number or no output. Here’s the driver function: int main(){ node *root, *num2; bt tree; root = new node; root->data = 12; root->left = num2; root->right = NULL; tree.root = root; num2 ..

I am currently making a merge sort algorithm but when i run the code i get an error says "terminate called after throwing an instance of ‘std::out_of_range". This is my code. template<typename T> void merge(std::vector<T> &vec, int l, int m, int r){ int i = l; int j = m + 1; int k = ..

#include <iostream> using namespace std; int main() { int arr = { 0 }; int n = 5, m; for (int i = 0; i < n; i++) arr[i] = i; cin >> m; int ele[m]; int pos[m]; n = n + m; for (int i = 0; i < m; i++) cin >> ele[i]; ..

I was solving the Next Permutation problem but I’m receiving the following error on Leetcode. Could any one point out what I am missing. Line 1034: Char 34: runtime error: addition of unsigned offset to 0x6020000002f0 overflowed to 0x6020000002ec (stl_vector.h) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34 class Solution { public: void nextPermutation(vector<int>& nums) { int n=nums.size(); int ..

#include<iostream> #include<string> using namespace std; void subseq(string s, string ans) { if (s.size() == 0) { cout <<ans<< endl; } char ch = s; int code = ch; string ros = s.substr(1); subseq(ros, ans); subseq(ros, ans+ch); subseq(ros, ans + std::to_string(code)); } int main() { cout<<subseq("AB", " "); return 0; } Error, as stated in IDE, ..

#include<iostream> #include<string> using namespace std; void subseq(string s, string ans) { if (s.size() == 0) { cout <<ans<< endl; } char ch = s; int code = ch; string ros = s.substr(1); subseq(ros, ans); subseq(ros, ans+ch); subseq(ros, ans + std::to_string(code)); } int main() { cout<<subseq("AB", " "); return 0; } Error, as stated in IDE, ..