class Solution {
public int[] shuffle(int[] nums, int n) {
int len = nums.length;
int[] res = new int[len];
int resIndex = 0;
for(int i=0; i < len/2; i++){//배열 중간까지만 진행
res[resIndex] = nums[i];//첫번째값
res[++resIndex] = nums[i+n];//두번째값은 n만큼 더한 위치
resIndex++;
}
return res;
}
}
static int utopianTree(int n) {
int h = 0;
for(int i = 0; i <= n; i++){
if(i==0){
h = 1;
continue;
}
if(i % 2 == 1){
h *= 2;
}else{
h += 1;
}
}
return h;
}
static int hurdleRace(int k, int[] height) {
int n = 0;
for(int i =0; i < height.length; i++){
int r = height[i] - k;
if(r > 0){
if(n < r){
n = r;
}
}
}
return n;
}
static int howManyGames(int p, int d, int m, int s) {
// Return the number of games you can buy
int salePrice = p;//세일 시작가격
int count = 0;//구매한 게임수
while(s >= salePrice ){
count++;//게임개수증가
s -= salePrice;//남은돈
//System.out.println("Buy salePrice="+salePrice+", count="+count+", s="+s);
if(salePrice > m){
salePrice -= d;//세일 적용
}
if(salePrice < m){//최저세일가 보장
salePrice = m;
}
}
return count;
}