Geeksforgeeks
Programming Logic Section
5/5 Answers
Programming Logic Section
5/5 Answers
👍3
Geeksforgeeks
Quantitive Section
5/5 Answers✅
Quantitive Section
5/5 Answers✅
👍1
Geeksforgeeks
Logical Section
5/5 Answers✅
Logical Section
5/5 Answers✅
👍1
public int maxGoodLength(int matrix[][]){
int N = matrix.length;
int M = matrix[0].length;
int maxGoodLength = 0;
for (int L = Math.min(N, M); L > 0; L--) {
outerLoop:
for (int i = 0; i <= N - L; i++) {
for (int j = 0; j <= M - L; j++) {
boolean allGreater = true;
for (int x = i; x < i + L; x++) {
for (int y = j; y < j + L; y++) {
if (matrix[x][y] < L) {
allGreater = false;
break;
}
}
if (!allGreater) {
break;
}
}
if (allGreater) {
maxGoodLength = L;
break outerLoop;
}
}
}
if (maxGoodLength > 0) {
break;
}
}
return maxGoodLength;
}
@Coding_000✅
int N = matrix.length;
int M = matrix[0].length;
int maxGoodLength = 0;
for (int L = Math.min(N, M); L > 0; L--) {
outerLoop:
for (int i = 0; i <= N - L; i++) {
for (int j = 0; j <= M - L; j++) {
boolean allGreater = true;
for (int x = i; x < i + L; x++) {
for (int y = j; y < j + L; y++) {
if (matrix[x][y] < L) {
allGreater = false;
break;
}
}
if (!allGreater) {
break;
}
}
if (allGreater) {
maxGoodLength = L;
break outerLoop;
}
}
}
if (maxGoodLength > 0) {
break;
}
}
return maxGoodLength;
}
@Coding_000✅
🔥2❤1👍1
int minimumMagic(int n, int m, vector<int> &price, vector<int> &magical_price)
{
int sum=0,count=0;
for(int i=0;i<n;i++)
{
sum+=price[i];
}
if(sum<=m)
{
return 0;
}
vector<int> vec;
for(int i=0;i<n;i++)
{
vec.push_back(price[i]-magical_price[i]);
}
sort(vec.begin(),vec.end());
for(int i=n-1;i>=0;i--)
{
sum-=vec[i];
count++;
if(sum<=m)
{
return count;
}
}
return -1;
}
@Coding_000
{
int sum=0,count=0;
for(int i=0;i<n;i++)
{
sum+=price[i];
}
if(sum<=m)
{
return 0;
}
vector<int> vec;
for(int i=0;i<n;i++)
{
vec.push_back(price[i]-magical_price[i]);
}
sort(vec.begin(),vec.end());
for(int i=n-1;i>=0;i--)
{
sum-=vec[i];
count++;
if(sum<=m)
{
return count;
}
}
return -1;
}
@Coding_000
👍2🔥1🥰1
class Solution{
public:
bool isBeautifulString(const string& s) {
unordered_map<char, int> freq;
for (char c : s) {
freq[c]++;
}
int oddCount = 0;
for (const auto& p : freq) {
if (p.second % 2 != 0) {
oddCount++;
}
}
return oddCount <= 1;
}
long long noOfPairs(vector<string> &box)
{
int count = 0;
int n = box.size();
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
string concatenated = box[i] + box[j];
if (isBeautifulString(concatenated)) {
count++;
}
}
}
return count;
}
};
@Coding_000✅
public:
bool isBeautifulString(const string& s) {
unordered_map<char, int> freq;
for (char c : s) {
freq[c]++;
}
int oddCount = 0;
for (const auto& p : freq) {
if (p.second % 2 != 0) {
oddCount++;
}
}
return oddCount <= 1;
}
long long noOfPairs(vector<string> &box)
{
int count = 0;
int n = box.size();
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
string concatenated = box[i] + box[j];
if (isBeautifulString(concatenated)) {
count++;
}
}
}
return count;
}
};
@Coding_000✅
🔥4👍1
All 3 codes uploaded...😃😎
Share @Coding_000❤️👨💻
Share @Coding_000❤️👨💻
🔥2😎2
👍2😍2🔥1🤩1
👍2❤1