# 카카오 경력 ###### tags: `Tag(코테)` ## 1 ### Q ![](https://i.imgur.com/eczM8gq.png) ![](https://i.imgur.com/chnuRC7.png) ![](https://i.imgur.com/PT5tG9n.png) ### A ``` class Result { /* * Complete the 'solution' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER x * 2. INTEGER y * 3. INTEGER z */ public static int solution(int x, int y, int z) { int bigger = Math.max(x, y); int distance = Math.abs(x-y); if(distance>z) return -1; return ( bigger + (Math.abs(distance-z)/2) ); } } ``` ### result ![](https://i.imgur.com/szhjf22.png) ![](https://i.imgur.com/xsEucoY.png) ## 2 ### Q ![](https://i.imgur.com/9npBXSz.png) ![](https://i.imgur.com/kQTS7ry.png) ### A ``` public static int solution(List<Integer> cost, int x) { long cnt = 0; long power[] = new long[cost.size()]; power[0] = 1; for(int k=1; k<cost.size(); k++){ power[k] = (power[k-1]*2)%1000000007; } for(int i=cost.size()-1; i>=0; i--){ if(x-cost.get(i)>=0){ x -= cost.get(i); cnt += power[i]%1000000007; } } return (int)(cnt%1000000007); } ``` ![](https://i.imgur.com/2916iWU.png) ## result ![](https://i.imgur.com/wNu9mAv.png) ## 3 ### Q ![](https://i.imgur.com/w99ZwuW.png) ![](https://i.imgur.com/Vjc28OW.png) ### A ``` class Result { /* * Complete the 'solution' function below. * * The function is expected to return an INTEGER. * The function accepts INTEGER_ARRAY box as parameter. */ public static int solution(List<Integer> box) { // Write your code here int max = 0; long sum = 0; for(int i=0; i<box.size(); i++){ sum += box.get(i); int now = (int)(sum/(i+1)); int div = (int)(sum%(i+1)); if(div>0){ now++; } max = Math.max(max, now); } return max; } } ``` ![](https://i.imgur.com/tNdA1f5.png) ### result ![](https://i.imgur.com/tEHqXG3.png)