HackerRank Java - Java Loops II

preview_player
Показать описание


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

I recently started learning Java and was solving problems on HackerRank when I came across this one. I couldn’t figure it out and started feeling pretty down, thinking I must be too dumb to solve even the “easy” problems. But it turns out this one wasn’t as easy as it looked, which makes me feel a bit better.

CircuitPulsePro
Автор

the "1" in the series (1.2 + b) is the exponent of 2 °, it is called "zero rule" every number to zero is equal to 1

saridrangel
Автор

this much tough and they kept that in easy ecction

ShajahanSmart
Автор

This is listed as "Easy" on hackerrank. Though there isn't much to it, I wouldn't call it easy tbh...

matthewstaton
Автор

This shit destroy me in 3 days and have to gain energy to comeback.

TonyLuu-dgdt
Автор

Keep going please thx alot, that really helped

zeyaddessouki
Автор

Thanks for the video, helped a lot. Keep doing the great work. Subscribing for more content.

iamniravkumarpatel
Автор

u can replace that 2 with "t" other wise it wont work with other 1st input then 2
thanks for solution.
Edit:Nah doesnt work replacing t with 2

MadMan-cfqy
Автор

I did this and i think it's way better to understand what's going on
for (int j = 0; j < n; j++) {
System.out.print( a += Math.pow(2, j) *b ); //literally the formula given
System.out.print(" ");
}
System.out.print("\n");

leonardonitolemoreira
Автор

Oh. so I didn't have to input a, b, and c all into one String variable like it said in the "sample input", and then convert each number from that String into an int, and store it somewhere... Darn it. If you haven't shared this I may have wasted another 3 hours on it. Thanks.

Cristero-Contra-el-vicio
Автор

hi bro my name is kiran from india slove the problem

kirankumar-ybgg
Автор

for(int j=0;j<n;j++){
a+=b;
System.out.print(a+" ");
b=b*2;
}
System.out.println();
bro love you
no need of if statement

bornfinder
Автор

my solution :
import java.util.*;
import java.io.*;

class Solution{
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int t=in.nextInt();
for(int i=0;i<t;i++){
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();

int y = a + b;
System.out.print(y + " ");
for(int j = 1; j<n ; j++){
int c = (int) Math.pow(2, j);
y = y + c * b;
System.out.print(y + " ");

}
System.out.println();
}
in.close();
}
}

sudenursenkal