본문 바로가기

전체 글88

Ajax 비동기 vs 동기 동기처리(Synchronous) : 클라이언트가 서버에게 데이터 요청을 하면 그 요청에 맞는 응답이 올때까지 다른 작업을 하지 않고(멈춰있음) 기다린다. 그 후에 요청에 맞는 응답을 받게 되면 그제야 다음 요청을 처리한다. 즉, 브라우저는 스크립트가 서버로부터 데이터를 수집하고 이를 처리한 후 페이지 나머지 부분이 모두 로드될 때까지 대기하는 것이다. 비동기처리(Asynchronous) : 클라이언트가 서버에게 데이터 요청을 한 후, 서버가 요청에 맞는 응답을 언제 줄지 모르기 때문에 무작정 기다리지 않고 비동기처리를 한다. 즉, 요청만 보내놓고 응답이 오지 않아도 다음 새로운 요청으로 넘어가버린다. (다른 작업이 가능) 여기서 자바스크립트 언어는 순차적 연산을 거치는 동기처리에 가깝다..
폰켓몬 풀이 import java.util.*; class Solution { public int solution(int[] nums) { int answer = 0; ArrayList list = new ArrayList(); for (int i : nums) { if (!list.contains(i)) { list.add(i); } } if(list.size()
2016년 풀이 class Solution { public String solution(int a, int b) { String answer = ""; int sum = 0; if(a==1){ sum = b; }else if(a==2){ sum = 31 + b; }else if(a == 3){ sum = 31+29+b; }else if(a == 4){ sum = 62+29+b; }else if(a == 5){ sum = 62+59+b; }else if(a == 6){ sum = 93+59+b; }else if(a==7){ sum = 93+89+ b; }else if(a == 8){ sum = 124+89+b; }else if(a == 9){ sum = 155+89+b; }else if(a == 10){ sum = ..
가운데 글자 가져오기 풀이 class Solution { public String solution(String s) { String answer = ""; if(s.length()%2 !=0){ answer += s.charAt(s.length()/2); }else{ answer += s.charAt((s.length()/2) -1); answer +=s.charAt(s.length()/2); } return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr
같은 숫자는 싫어 풀이 import java.util.*; public class Solution { public int[] solution(int []arr) { Stack stack = new Stack(); stack.push(arr[0]); for (int i = 1; i < arr.length; i++) { if(stack.peek() != arr[i]) { stack.push(arr[i]); } } int[] answer = new int[stack.size()]; for (int j = 0; j < answer.length; j++) { answer[j] = stack.get(j); } return answer; } } 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞..
나누어 떨어지는 숫자 배열 풀이 import java.util.*; class Solution { public int[] solution(int[] numlist, int divisor) { ArrayList list = new ArrayList(); for (int x : numlist) { if (x % divisor == 0) { list.add(x); } } int[] answer = null; if (list.size() != 0) { answer = new int[list.size()]; for (int i = 0; i < list.size(); i++) { answer[i] = list.get(i); } Arrays.sort(answer); } else { answer = new int[1]; answer[0] = -..