본문 바로가기

Algorithm/Code Fights (Code Signal)

CodeSignal Intro Databases #4 ProjectsTeam. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, ..

CodeSignal Intro Databases #4 ProjectsTeam. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, 데이터베이스, sql, query, 쿼리

 

 

CodeSignal Intro Databases #4

Q.

 You've been promoted and assigned to a new project. The problem is, you don't know who you are working with and your predecessor has vanished without a trace! Luckily, each project in your company keeps its own activity database, which you are going to use to find out the names of your new colleagues.

Information about the project's activity is stored in table projectLog, which has the following structure:

  • id: unique action id;
  • name: the name of the person who performed the action;
  • description: the description of the action;
  • timestamp: the timestamp of the action.

 넌 승진해서 새로운 프로젝트를 맡게 되었다. 문제는, 누구랑 일하는지도 모르고 / 전임자는 흔적없이 사라졌다. 운좋게, 회사의 각 프로젝트는 활동 데이터베이스를 갖고 있는데, 디비를 사용해서 새 동료들의 이름을 찾을 수 있다.

프로젝트 활동내역에 관한 정보는 projectLog 테이블에 저장되어 있고, 구조는 다음과 같다.

  • id: 유일한 활동 아이디
  • name: 활동을 한 사람의 이름
  • description: 활동의 내역
  • timestamp: 활동의 시간스탬프

 

You only have access to the project's most recent history, but this should be enough for you. You've decided that finding everyone who interacted with the project in this period is the best way to start.

Given the table projectLog, build a new results table with a single name column that contains the names of the project's contributors sorted in ascending order.

 

 프로젝트의 가장 최신 내용들에만 접근할 수 있지만, 충분하다. 이 기간에 해당 프로젝트에 활동한 모든 이들을 찾는게 시작하기 가장 좋은 방법이라고 생각했다.

 주어진 projectLog 에서, 새로운 결과 테이블을 만드는데, 이름 한개의 컬럼이 있고, 오름차순 정리한다. (중복 X)

 

Example

 

For the following table projectLog

 

id

name

description

timestamp

1 James Smith add new logo 2015-11-10 15:24:32
2 John Johnson update license 2015-11-10 15:50:01
3 John Johnson fix typos 2015-11-10 15:55:01
4 James Smith update logo 2015-11-10 17:53:04
5 James Smith delete old logo 2015-11-10 17:54:04
6 Michael Williams fix the build 2015-11-12 13:37:00
7 Mary Troppins add new feature 2015-11-08 17:54:04
8 James Smith fix fonts 2015-11-14 13:54:04
9 Richard Young remove unneeded files 2015-11-14 00:00:00
10 Michael Williams add tests 2015-11-09 11:53:00

 

the output should be

 

name

James Smith
John Johnson
Mary Troppins
Michael Williams
Richard Young
  • [execution time limit] 10 seconds (mysql)

 

Process

// Process 
//1. You should SELECT name in distinct

//2. In projectLog table

//3. Order by name in ascending

 

 

// 처리과정

//1. name 을 찾는데 중복을 없앤다.

//2. projectLog table 에서,

//3. 정렬은 name 오름차순

 

 

Code.. lemme see example code!!!

코드.. 예제코드를 보자!!!

 

 

/*Please add ; after each select statement*/
CREATE PROCEDURE projectsTeam()
BEGIN
	SELECT DISTINCT name FROM projectLog
    ORDER BY name ASC;
END

 

 

 

Something else you might like...?

 

2019/10/23 - [Algorithm/Code Fights (Code Signal)] - CodeSignal Intro Databases #1 ProjectList. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접, ..

2019/10/20 - [Algorithm/Leet Code] - LeetCode #181 EmployeesEarningMoreTheirManagers. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면..

 

 

2019/09/04 - [Programming/C++] - How to sort vector in C++, 벡터 정렬하는 방법,sorting,배열,stl,씨쁠쁠,example code,예제코드,표준라이브러리

 

 

2019/10/09 - [Computer/General] - 정보처리기사 실기/필기 - IT신기술동향_전산영어 요점 정리

2019/10/07 - [Computer/General] - 정보처리기사 실기/필기 - 업무 프로세스 요점 정리

 

 

2019/08/14 - [Life/Item review] - Mi Band 4 review, 미밴드4 후기, 장점, 단점, 리뷰, 한글, global review, 미밴드4 글로벌 후기, 리뷰, 구매, 사용방법, setting, 세팅, ProsNCons

 

 

2019/08/27 - [Programming] - 개발자 선배들에게서 배운 것들. Things I Learnt from a Senior Software Engineer. 코딩 잘하는 방법, how to code well, 소프트웨어,프로그래머,programmer

 

 

2019/04/14 - [Programming/C++] - C++ Math - sqrt (square root, 제곱근, 루트). stl, math.h, 씨쁠쁠, example code, 예제코드

 

 

2018/10/19 - [Programming/Design Pattern ] - Design pattern - Prototype (디자인패턴 - 프로토타입) / Java C++ C#

 

 

2019/01/12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #60 sudoku. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

2019/01/12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #59 spiralNumbers. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

2019/01/08 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #58 messageFromBinaryCode. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

 

 

2019/09/17 - [Algorithm/Leet Code] - LeetCode #841 KeysAndRooms. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,그래프,Graph,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/08/28 - [Algorithm/Leet Code] - LeetCode #821 ShortestDistanceToACharacter. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접..

 

 

2018/12/28 - [Programming/Software Architecture] - Perfecting OO's Small Classes and Short Methods. 완벽한 객체지향의 작은 클래스와 짧은 메소드, Book:ThoughtWorks Anthology, Java,cpp,자바,oop,좋은코드,객체지향프로그래밍 - (#9, Tell, Don't Ask)

2018/12/26 - [Programming/Software Architecture] - Perfecting OO's Small Classes and Short Methods. 완벽한 객체지향의 작은 클래스와 짧은 메소드, Book:ThoughtWorks Anthology, Java,cpp,자바,oop,좋은코드,객체지향프로그래밍 (1)

 

 

2019/01/14 - [Programming/Java] - 자바 메모리 누수 체크/확인/고치는 방법, Memory leak check/fix in Java application, cleanCode/좋은코드/oop/객체지향

 

 

2019/02/19 - [Life/Health care] - Lysine 라이신 usage/side effects/dosage 효과/효능/부작용/성인,소아 용법, 복용법

2019/02/16 - [Life/Health care] - Finasteride 피나스테라이드,탈모약 usage/side effects/dosage 효능/부작용/효과/sexual effect/두타스테라이드/프로페시아/propecia/finpecia/카피약/copy drug/hair loss

2019/02/25 - [Life/Health care] - Folic Acid 엽산 vitaminB9,비타민M usage/side effects/dosage 효과/효능/부작용/성인,소아 용법, 복용법

2019/02/28 - [Life/Health care] - Vitamin K, 비타민 K usage/side effects/dosage 효능/부작용/성인,소아 용법

2019/03/03 - [Life/Health care] - Vitamin B1, Thiamine, 비타민 B1, 티아민 usage/side effects/dosage 효능/부작용/성인,소아 용법