일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
- Generator
- Python
- 밴픽
- 109. Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- iterator
- LeetCode
- 파이썬
- 운영체제
- 시바견
- Python Code
- Regular Expression
- t1
- concurrency
- Substring with Concatenation of All Words
- shiba
- Protocol
- 43. Multiply Strings
- 프로그래머스
- 30. Substring with Concatenation of All Words
- Class
- Python Implementation
- 715. Range Module
- 315. Count of Smaller Numbers After Self
- DWG
- Decorator
- Convert Sorted List to Binary Search Tree
- data science
- attribute
- kaggle
- Today
- Total
목록Computer Science (392)
Scribbling
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..
#include #include class Solution { public: vector threeSum(vector& nums) { using namespace std; sort(nums.begin(), nums.end()); vector ret; for (size_t i=0; i 0 and nums[i] == nums[i-1]) { continue; } size_t j = i + 1, k = nums.size() - 1; while (j < k) { int num1 = nums.at(i), num2 = nums.at(j), num3 = nums.at(k); int summed = num1 + num2 + num3; if (summed == 0) { vector temp = {num1, num2, nu..
First thing first: To implement an expression tree with "Postfix", we can easily do so with a stack. For the evaluation part: "ABC" might be a bit unfamiliar, but all you need to know about it here is that you cannot initiate an instance with the ABC class (in this case Node class). In addition, an abstract method must be implemented in the child class. import abc from abc import ABC, abstractme..
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { ListNode* curPtr = new ListNode(0); ListNode* ret = curPtr; int sum=0, carry =..
#include #include using namespace std; class Solution { public: vector twoSum(vector& nums, int target) { vector res; unordered_map hash; for (int i = 0; i < nums.size(); i++) { int num = target - nums[i]; // found if (hash.find(num) != hash.end()) { res.push_back(hash[num]); res.push_back(i); return res; } hash[nums[i]] = i; } return res; } }; int main() { vector vec{ 2, 7, 11, 15 }; Solution()..