leetcode.com/problems/jewels-and-stones/ Jewels and Stones - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com argument로 2개의 string을 input 함수는 2개의 string을 parameter로 받아와서, 첫번째 문자열의 원소별로 두번째 문자열의 원소와 같은것이 몇개 있는지를 return함. 2중 for문 class Solution { public: int numJewelsInStones(string j..
leetcode.com/problems/number-of-good-pairs/ Number of Good Pairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/eenmys/btq1I7x9L6X/qK2S6Rbi3czhtZH68ogFjk/img.png)
컴포넌트를 통해 UI를 재사용 가능한 개별적인 여러 조각으로 나누고, 각 조각을 개별적으로 살펴볼 수 있다. 컴포넌트는 Javascript의 함수와 유사하다. props라는 parameter를 받아서 화면에 어떻게 표시되는지 작성한다. Components는 함수 컴포넌트와 클래스 컴포넌트가 있다. 이전에 간략히 작성해둔 함수 컴포넌트와 클래스 컴포넌트에 대한 내용이다 kmj24.tistory.com/22 [React]Function Component, Class Component 컴포넌트를 function으로 선언하는것과, class로 선언하는 각각의 방식이 있다. 2가지 선언방식은 어떤점에서 차이가 있을까? 이름 그대로 class component(이하 CC)는 class를 기반으로 작성되는 컴포넌 k..
Element는 React Application의 가장 작은 단위이다. //Element의 형태 const element = Element React의 Element는 일반 객체(plain object)를 쉽게 생성할 수 있다. React DOM은 React Element와 일치하도록 DOM을 업데이트 한다. HTML 파일 어딘가 가 있다고 가정해 봤을 때, 이것을 root DOM node라고 한다. React로 구현된 Application은 일반적으로 하나의 root DOM node가 있고, react를 기존 Application에 통합하려는 경우 원하는 만큼 많은 수의 독립된 root DOM node를 가질 수 있다. React 엘리먼트를 root DOM node에 렌더링 하려면 둘다 ReactDOM..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/cavSQu/btq1MrIxoOY/Yko3wnB9mQwGku8TbqKwJk/img.png)
참조자(references) 다음의 코드는 함수에 참조자를 인자값으로 넘겨준다. pub fn references(){ let s1 = String::from("hello"); let len = calculate_length(&s1); println!("{}, {}", s1, len); } fn calculate_length(s: &String) -> usize{ return s.len(); } 여기서 calculate_length 함수에 s1을 넘기는게 아닌 s1의 참조자를 넘겼기 때문에 함수 호출 이후에도 s1을 그대로 사용할 수 있다. 참조자를 활용하면 소유권을 넘기지 않고 값을 참조할 수 있다. &이 참조자이다 참조자가 가리키는 값은 참조자가 스코프를 벗어났을 때에도 메모리가 해제되지 않는다. fn..
JSX 는 Javascript를 확장한 문법입니다. Javascript모든 기능이 포함되어 있고, React element를 생성합니다. const element = Hello, React; React는 마크업과 Logic을 둘다 포함하는 Component라는 느슨한 연결의 유닛으로 SOC(separation of concerns, 관심사 분리)합니다. JSX에서는 Javascript 표현식을 넣을 수 있다 아래의 코드를 보면 name이라는 변수를 중괄호로 감싸 사용하고 있습니다. const name = "JSX"; const element = This is {name} ReactDOM.render( element, document.getElementById('root') ); JSX문법은 html 태그..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/UpTSH/btq1FCcFia4/9OIyYAdntAePVedozc2Y70/img.png)
소유권이란? 메모리를 관리하는 Rust언어 특성이다. C/C++은 메모리를 직접 할당하고 해제하거나 Java, C# 등은 GC를 이용하여 메모리를 관리한다. Rust는 소유권이라는 특성으로 메모리 관리가 가능하다. 소유권의 규칙 1. Rust의 각각의 값은 해당 값의 owner라고 불리는 변수를 가지고 있다. 2. 한번에 딱 하나의 owner만 존재할 수 있다. 3. owner가 scope 밖으로 벗어날 때 값은 버려진다. 소유권의 예제 1. 변수의 스코프 아래의 함수를 실행해보면 "hello"가 출력된다. 스코프 내에 있는 변수의 유효범위는 변수가 선언된 시점부터 스코프의 밖으로 벗어날 때 까지 지속된다. 이는 타 프로그래밍 언어와 비슷하다. pub fn ownership(){ let s = "hell..
![](http://i1.daumcdn.net/thumb/C148x148/?fname=https://blog.kakaocdn.net/dn/bcFzCr/btq1uvzG5fB/KljNaUaWwmmT5cYkBPdja0/img.png)
programmers.co.kr/learn/courses/30/lessons/42883 코딩테스트 연습 - 큰 수 만들기 programmers.co.kr #include #include #include using namespace std; priority_queue total; vector temp; string ExtractString(string object, vector position) { if (object.size() < position.size()) return ""; int cnt = 0; string tmp; for (int n = 0; n < object.size(); n++) { if (cnt < position.size()) { if (n == position[cnt]) { cnt+..