본문 바로가기

전공지식

(21)
136. Single Number - 원문Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? - 해석정수 배열을 감안할 때 모든 요소는 하나만 제외하고 두 번 나타납니다. 그 하나를 찾아라.노트:알고리즘의 선형 런타임 복잡성이 있어야합니다. 여분의 메모리를 사용하지 않고 구현할 수 있습니까? - 회고 이 문제를 처음 봤을 때 leetcode 문제 중 448. Find All Numbers Disappeared in an Arr..
448. Find All Numbers Disappeared in an Array - 원문 Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space. - 해석 1 ≤ a [i] ≤ n (n은 배열의 크기) 인 정수 배열이 주어지면 일부 요소는 두 번 나타나고 다른 요소는 한 번 나타납니다...
461. Hamming Distance - 원문 The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. - 해석 두 정수 사이의 해밍 거리는 비트가 다른 위치의 갯수입니다. 두 개의 정수 x와 y가 주어지면, 해밍 거리를 계산하십시오. Note: 0 ≤ x, y < 231. Example:Input: x = 1, y = 4 Output: 2 Explanation: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ The above arrows point to positions where ..
5장 CPU Schedule
[백준][DP][9465]스티커 URL : https://www.acmicpc.net/problem/9465 - 소스코드 public class Main { public static void main(String[] args) throws FileNotFoundException { //Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(new FileInputStream("input.txt")); int cases = sc.nextInt(); int[][] answerArr; int N; int[][] arr; while(cases-- > 0){ N=sc.nextInt(); arr=new int[2][N]; for(int i=0; i
[백준][DP][2011] 암호코드 - URL : https://www.acmicpc.net/problem/2011 - 소스코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static int mod = 1000000; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input = br.readLine(); int length = ..
[백준][DP][2193] 이친수 URL : https://www.acmicpc.net/problem/2193 - 소스코드 · 2차원 다이나믹 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[][] dp = new long[n+1][2]; // 이친수는 0으로 시작하지 않는다. dp[1][1] = 1; for(int i=2; i d[i-2] for (int i=3; i
[백준][DP][11057] 오르막 수 URL : https://www.acmicpc.net/problem/11057 - 소스코드 public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] dp = new int[n+1][10]; for(int i=0; i