MapleStory Finger Point Cute Line Smiley Blinking Hello Kitty Angel MapleStory Finger Point

๐Ÿƒ‍โ™€๏ธprogrammers/Java

หšโ‚Šโœฉโ€งโ‚Š ๐Ÿ“ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค java ๊ฒน์น˜๋Š” ์„ ๋ถ„์˜ ๊ธธ์ด หšโ‚Šโœฉโ€งโ‚Š

HYEJU01 2024. 6. 3. 10:45

 

import java.util.*;
class Solution {
    public int[] solution(int[] numlist, int n) {

        int size = numlist.length;
        for(int i=0; i<size-1; i++){
            for(int k=i+1; k<size; k++){
                int a = (numlist[i] - n) * (numlist[i] > n ? 1 : -1);
                int b = (numlist[k] - n) * (numlist[k] > n ? 1 : -1);
                if(a > b || (a == b && numlist[i] < numlist[k])){
                    int temp = numlist[i];
                    numlist[i] = numlist[k];
                    numlist[k] = temp;
                }

            }
        }
        return numlist;
    }
}

 

 

 

[์‹คํŒจ]

class Solution {
    public int solution(int[][] lines) {
        int answer = 0;
        
        int x1 = lines[0][0], y1 = lines[0][1];
        int x2 = lines[1][0], y2 = lines[1][1];
        int x3 = lines[2][0], y3 = lines[2][1];
        
        if (y1 > x2){
            answer += (y1 - x2);
        }else if (y1 > x2 && x1 >= x2){
            answer += (y2 - x1);
        }
            
        if (y2 > x3){
            if (x3 < x1){
                answer += (y2 - x1);
            } else if ( x3 > x1){
                answer = (y2 - x3);
      
            }
        }else if (x2 < x3 && x1 >= x3) {
            answer +=(y3 - x3);
        }
        

        return answer;
    }
}

 

[ํฌ๊ธฐ]  ๋ฐฐ์—ด์— ๋„ฃ์–ด์„œ ํ•ด๋ณด๋ ค๊ณ  ํ–ˆ์ง€๋งŒ ๋„ˆ๋ฌด ๋ณต์žกํ•ด์ ธ์„œ ํฌ๊ธฐ

import java.lang.Math;

class Solution {
    public int solution(int[][] lines) {
        int answer = 0;
        
        int[] tmp = new int[200];
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        
        int x1 = lines[0][0], y1 = lines[0][1];
        int x2 = lines[1][0], y2 = lines[1][1];
        int x3 = lines[2][0], y3 = lines[2][1];

        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 2; j++){
                if (max < lines[i][j]){
                    max = lines[i][j];
                }
                else if (min > lines[i][j]){
                    min = lines[i][j];
                }
            }
        }
    
         for (int i = 0; i < 3; i++){
                for (int j = 0; j < 2; j++){
                     for (int z = min; z < min; z++){
                        if (lines[i][j] == z){
                            if ( z < 0){
                                tmp[Math.abs(z-1)]++;
                            }else {
                                tmp[z*2-1]++;
                            }
                                
                    }
                }
            }
        }
       int F = 0;
        int L = 0;
        
         for (int i=0; i<tmp.length; i++){
             if (tmp[i] == 2){
                 F = tmp[i];
                 break;
             }
         }
         for (int i=0; i<tmp.length; i++){
             if (tmp[i] == 2){
                 L = tmp[i];
             }
         }  
           
        
        /*
        if (y1 > x2){
            answer += (y1 - x2);
        }else if (y1 > x2 && x1 >= x2){
            answer += (y2 - x1);
        }
            
        if (y2 > x3){
            if (x3 < x1){
                answer += (y2 - x1);
            } else if ( x3 > x1){
                answer = (y2 - x3);
      
            }
        }else if (x2 < x3 && x1 >= x3) {
            answer +=(y3 - x3);
        }
        */

        return ;
    }
}