일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Generator
- attribute
- 715. Range Module
- t1
- 파이썬
- data science
- kaggle
- Decorator
- 43. Multiply Strings
- DWG
- Regular Expression
- 밴픽
- 프로그래머스
- Python
- 운영체제
- Substring with Concatenation of All Words
- 컴퓨터의 구조
- Convert Sorted List to Binary Search Tree
- Python Code
- concurrency
- Protocol
- 30. Substring with Concatenation of All Words
- LeetCode
- shiba
- 315. Count of Smaller Numbers After Self
- Class
- iterator
- 시바견
- 109. Convert Sorted List to Binary Search Tree
- Python Implementation
- Today
- Total
목록Computer Science/Java (19)
Scribbling
class Solution { public int[] topKFrequent(int[] nums, int k) { Map counter = new HashMap(); for (int num: nums) { counter.put(num, counter.getOrDefault(num, 0) + 1); } Comparator comparator = (list1, list2) -> { for (int i = 0; i < list1.size(); i++) { int value = list1.get(i) - list2.get(i); if (value != 0) return value; } return 0; }; Queue pq = new PriorityQueue(comparator); for (var key: co..
class Solution { public List groupAnagrams(String[] strs) { Map map = new HashMap(); for (String str: strs) { int[] count = new int[26]; Arrays.fill(count, 0); for (char c: str.toCharArray()) { count[c - 'a']++; } StringBuilder sb = new StringBuilder(); for (int i=0; i
class Solution { public int[] twoSum(int[] nums, int target) { Map map = new HashMap(); for (int i=0; i
class Solution { public boolean isAnagram(String s, String t) { if (s.length() != t.length()) return false; Map counter1 = new HashMap(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); counter1.merge(c, 1, Integer::sum); } Map counter2 = new HashMap(); for (int i = 0; i < t.length(); i++) { char c = t.charAt(i); counter2.merge(c, 1, Integer::sum); } for (Character c : counter1.keyS..
class Solution { public boolean containsDuplicate(int[] nums) { Set numSet = new HashSet( Arrays.stream(nums).boxed().collect(Collectors.toSet()) ); return nums.length != numSet.size(); } }
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode ret = new ListNode(); ListNode cur = ret; int carry = 0; while (l1 != null || l2 !=..
class Solution { public List threeSum(int[] nums) { List ret = new ArrayList(); Arrays.sort(nums); int N = nums.length; for (int i = 0; i 0 && nums[i] == nums[i-1]) { continue; } int j = i + 1, k = N - 1; while (j < k) { int n1 = nums[i], n2 = nums[j], n3 = nums[k]; int sum = n1 + n2 + n3; if (sum == 0) { List temp = List.of(n1, n2, n3); ret.add(temp); while (j < k && num..
5장 1. ==과 != 기본 타입의 경우 값을 비교하지만, 참조 타입의 경우는 주소값을 저장하므로 ==로 비교하면 같은 객체인지를 확인한다. 참조 타입 변수는 null을 가질 수 있다. null과의 비교는 == 혹은 !=를 사용함. 2. 배열의 생성 char[] chars = { 'a', 'b', 'c', 'a' }; 3. 2차원 배열 int[][] scores = new int[5][]; 6장 1. 클래스 - 하나의 소스 파일에 소스 파일명과 동일한 클래스만 public class로 사용 가능함 - 여러 개의 클래스를 선언한 소스 파일을 컴파일하면 클래스 선언 수만큼 바이트코드 파일(.class)이 생김 - 흔히 자바 프로그램은 하나의 실행 클래스와 여러 개의 라이브러리 클라스로 이루어짐 2. 생성자 ..
This post will briefly summarize things I picked up about Java. I'll only handle stuff that is totally different from Python, C++, JavaScript context & syntax. In Java, all classes are Reference Types. Except for primitive types, all the instances or objects are stored on Heap. 1. String 1.1. Methods charAt(int): The charAt method accepts an index value as its input and returns the character loc..