본문 바로가기

algorithm62

Hackerrank The Grid Search 풀이 The Grid Search 문제 : https://www.hackerrank.com/challenges/the-grid-search/problem 풀이 및 시간복잡도 주석에 풀이 및 시간 복잡도 써놓음. public class TheGridSearch { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0 ; i < t ; i++) { /** grid row */ int R = in.nextInt(); /** grid column */ in.. 2020. 10. 7.
leetcode Employees Earning More Than Their Managers 풀이 self 조인 leetcode 문제 https://leetcode.com/problems/employees-earning-more-than-their-managers/ 풀이 주의할 점은 a.managerId = b.id 임. a.managerId 가 3,4 = b 테이블과 비교했을 때, 1,2번이 조인 결과로 나옴. select a.name as Employee from Employee a inner join Employee b on a.managerId = b.Id where a.salary > b.salary ; 2020. 9. 30.
leetcode Reformat Department Table 풀이 CASE WHEN PIVOT LEETCODE 문제 https://leetcode.com/problems/reformat-department-table/ 요약하면 department 별 1~12월 수입을 출력. 풀이 select id ,sum(case when month = &#39;Jan&#39; then revenue end) as Jan_Revenue ,sum(case when month = &#39;Feb&#39; then revenue end) as Feb_Revenue ,sum(case when month = &#39;Mar&#39; then revenue end) as Mar_Revenue ,sum(case when month = &#39;Apr&#39; then revenue end) as .. 2020. 9. 29.
hackerrank case when 문제 풀이 문제 https://www.hackerrank.com/challenges/what-type-of-triangle/problem?h_r=internal-search 요약하면 A,B,C 세 길이가 주어지고, A,B,C 를 각각 판단해서 이름을 alias 붙여주면 됨. 풀이 select case when (A + B 2020. 9. 27.