Light Blue Pointer
본문 바로가기

Coding Test115

4. Median of Two Sorted Arrays 문제 주소 https://leetcode.com/problems/median-of-two-sorted-arrays/ Median of Two Sorted Arrays - LeetCode Can you solve this real interview question? Median of Two Sorted Arrays - Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1 leetcode.com 문제 Given two sorted arrays .. 2023. 7. 20.
3.Longest Substring Without Repeating Characters 문제 주소 https://leetcode.com/problems/longest-substring-without-repeating-characters/ int: input = list(map(int, str(num))) temp = [] longest = 0 i=0 j=1 longest = thislist[i:j] while(jlongest): longest = temp break; i++; return longest; 처음에는 i를 고정시키고 j만 움직이려고 했는데 곧 그게 잘못되었단걸 알게되었다 왜냐하면 모든 원소가 새 원소 후보랑 같은지 비교해야 했기 때문이다 그래서 while루프 대신에 for 루프를 쓰기로 했다 To insert at the end, do this temp.insert(len(te.. 2023. 7. 20.
2. Add Two Numbers 이때 푼 풀이에서는 숫자를 다루다보니 소숫점이 많아지면 값이 미묘하게 달라져서 스트링으로 취급해봄 : https://greedydeveloper.tistory.com/64 Given Problem You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the .two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading ze.. 2023. 7. 20.
1.1 Two Sum 파생문제(자작) 문제 똑바로 안 읽고 첫줄을 알아서 스킵해버림 그 결과 엄청나게 어려운 문제로 바뀌었다 이거 푼다고 3시간이나 붙어있었는데 ㅋㅋㅋㅋ 그럴 문제가 아니었음을... input List에 들어있는 숫자의 조합으로 결과값을 만든다 List[int]: col = 1; row = len(nums); for i in range(len(nums)): col = col*2 array = [[0 for c in range(col)] for r in range(row)] end = col; for i in range(row): end = end/2; count = False; for j in range(col): if(j%end == 0): count = not count; if(count == True): array[i].. 2023. 1. 2.
1.Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1:Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1]. Exa.. 2023. 1. 2.
프로그래머스 행렬의 덧셈 문제 설명 행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행, 같은 열의 값을 서로 더한 결과가 됩니다. 2개의 행렬 arr1과 arr2를 입력받아, 행렬 덧셈의 결과를 반환하는 함수, solution을 완성해주세요. 제한 조건 행렬 arr1, arr2의 행과 열의 길이는 500을 넘지 않습니다. 입출력 예 arr1arr2return [[1,2],[2,3]] [[3,4],[5,6]] [[4,6],[7,9]] [[1],[2]] [[3],[4]] [[4],[6]] Java class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int [][] answer = new int [arr1.length][arr1[0].length]; f.. 2021. 8. 9.
프로그래머스 직사각형 별찍기 문제 설명 이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다. 별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요. 제한 조건 n과 m은 각각 1000 이하인 자연수입니다. java import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for (int i = 0;i 2021. 8. 1.