leetcode3 [LeetCode] #4 Median of Two Sorted Arrays Median of Two Sorted ArraysxThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume nums1 and nums2 cannot be both empty. 중간값 (Median)을 구하라는 문제이다.홀수개일 때는 중간값을, 짝수개일때는 중간 값 2개의 평균을 반환하면 된다. xxxxxxxxxxclass Solution { public double findMedianSortedArrays(int[] nums1, .. 2019. 12. 8. [LeetCode] #3 Longest Substring Without Repeating Characters Longest Substring Without Repeating CharactersxGiven a string, find the length of the longest substring without repeating characters. 중복되는 알파벳이 없는 가장 최장의 substring을 구하라는 문제이다.내 풀이부터 우선 보자. xclass Solution { public int lengthOfLongestSubstring(String s) { int answer = 0; String tmp = ""; for (int i = 0; i 2019. 12. 5. [LeetCode] #1 Two Sum Two SumxGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same element twice. 첫번째 문제 답게 쉬운 문제가 나왔다.그런데 뭔가 멋있게 풀고싶은 마음이 너무 드글드글해서,회사 제품 특성상 낮은 jdk버전에도 사용 가능한 코드만 짜다보니 간단하면서도 최근 jdk(라고 해봐야 자바8이지만..ㅎㅎ)에서 사용 가능한 방법으로 풀고싶었다. 그래서 우선 스트림을 사용해봤다.xxxxxxxxxximport.. 2019. 12. 5. 이전 1 다음