개인 공부
-
vector-icons : 리액트 네이티브에서 벡터 아이콘 사용하기개인 공부/React Native 2021. 7. 10. 20:45
import { MaterialCommunityIcons } from '@expo/vector-icons'; vector-icons는 Expo 프로젝트에서 기본으로 설치되는 라이브러리이며 위와 같이 import 해서 사용한다. 이외에도 react-native-vector-icons 라이브러리를 설치하여 벡터 아이콘을 사용할 수도 있다. vector-icons 에서 제공하는 아이콘 목록 @expo/vector-icons directory icons.expo.fyi react-native-vector-icons 공식 깃허브 oblador/react-native-vector-icons Customizable Icons for React Native with support for image source and ..
-
[GeekforGeeks] Key Pair개인 공부/알고리즘 2021. 5. 30. 19:23
Key Pair 문제 n개의 양의 정수값을 가지는 배열에서 두 수의 합이 정확히 특정 숫자 x가 되는 원소가 존재하는지 여부를 반환하여라. class Solution { boolean hasArrayTwoCandidates(int arr[], int n, int x) { // code here HashMap pairs = new HashMap(); for (int i = 0; i < arr.length; i++) { if (pairs.containsValue(arr[i])) return true; else pairs.put(arr[i], x - arr[i]); } return false; } }이제 이 문제는 아예 푸는 법을 외워버렸다...😅
-
[LeetCode] Climbing Stairs개인 공부/알고리즘 2021. 5. 18. 01:56
Climbing Stairs 처음으로 직접 맞힌 동적 프로그래밍 문제...!!!!!!!😭😂 class Solution { public int climbStairs(int n) { int [] counts = new int[n+1]; counts[1] = 1; if (n > 1) counts[2] = 2; for (int i = 3; i 1 2 -> 2 3 -> 1+1+1 / 1+2 / 2+1 4 -> 1+1+1+1 / 1+2+1 / 1+1+2 / 2+1+1 / 2+2 ... 그리고 나열한 것들을 뚫어지게 쳐다봤다..^-^.. 1+1+..+1 제외하면 바로 전이랑 관련이 있나 생각해봤다. (답은 아니지만 암튼 그렇게도 생각해봤다.) 내가 나열한 목록은 순서 없이 마구잡이로 나열된 것이라는 생각이 들었다. ..
-
[LeetCode] Flip Equivalent Binary Trees개인 공부/알고리즘 2021. 5. 16. 22:11
Flip Equivalent 처음 코드 class Solution { public boolean flipEquiv(TreeNode root1, TreeNode root2) { if (root1 == null && root2 == null) return true; if (root1.val != root2.val || root1.left.val != root2.left.val && root1.left.val != root2.right.val || root1.right != root2.left.val && root1.right.val != root2.right.val) return false; boolean equiv1, equiv2; if (root1.left.val == root2.left.val) { e..
-
[LeetCode] Valid Anagram개인 공부/알고리즘 2021. 5. 8. 07:30
Valid Anagram My Solution : class Solution { public boolean isAnagram(String s, String t) { if (s.length() != t.length()) return false; char [] sArray = s.toCharArray(); char [] tArray = t.toCharArray(); Arrays.sort(sArray); Arrays.sort(tArray); if (Arrays.equals(sArray, tArray)) return true; else return false; } } 마지막에 그냥 return Arrays.equals(sArray, tArray)라고 작성하면 되는 거였다..ㅠㅠ .sort() 메소드 사용할 경우..
-
[Leetcode] Valid Parentheses개인 공부/알고리즘 2021. 4. 25. 23:20
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. import java.util.Stack; import java.util.Scanner; public class Solution { public boolean isValid(String s) { Stack stack = new Stack(); ch..
-
자바스크립트 ES6 문법 정리 - 템플릿 문자열개인 공부/JavaScript 2021. 4. 25. 16:32
기존 자바스크립트에서는 병합 연산자(+)를 사용해서 문자열과 변수를 연결했다. ES6에서는 코드의 가독성을 더욱 높이기 위해 템플릿 문자열을 도입했다. // 템플릿 문자열 사용 예시 var string1 = '안녕하세요'; var string2 = '반갑습니다'; var greeting = `${string1} ${string2}`; var operator1 = `연산 결과는 ${a * b}입니다.`; 템플릿 문자열의 특징 작은 따옴표가 아니라 백틱으로 문자열을 표현한다. ${} 안에 변수를 넣는다. enter를 눌러서 줄을 바꾸는 것도 가능하다. 따라서 \n을 사용하지 않아도 된다. $ 기호 안에 연산을 포함할 수 있다.
-
처음 배우는 리액트 네이티브 : 7~8장 정리개인 공부/React Native 2021. 3. 29. 23:03
7장 Context API Context API : 데이터를 전역적으로 관리하고 사용할 수 있도록 하는 기능. 스타일드 컴포넌트가 대표적인 예시이다. Context API를 이용한 전역 상태 관리 일반적으로 리액트 네이티브에서는 데이터는 부모 컴포넌트에서 자식 컴포넌트로 전달된다. 데이터를 사용하는 컴포넌트가 많다면 최상위 컴포넌트(App)에서 상태를 관리하여야 한다. 그러나 이런 방법은 관리하는 상태가 추가되거나 변경되는 경우 과정에 속한 모든 컴포넌트를 찾아서 수정해야 하기 때문에 개발 단계뿐 아니라 유지보수에도 매우 불편하다. Context API를 이용하여 Context를 생성하면 중간 과정의 컴포넌트들을 거치지 않고 데이터를 바로 받아올 수 있다. cosnt Context = createCont..