일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Programmers 배열의 유사도
- 알고리즘
- 프로그래머스 가위바위보 풀이
- 주니어개발자
- 춥고더운우리집
- 프로그래머스 배열의 유사도 파이썬
- 비지니스 레이어
- BigO notation
- programmers 배열 회전
- 스프링 시스템 구조
- 가위바위보 풀이
- 특정문자 제거하기
- 프로그래머스 가위바위보
- 춥고 더운 우리 집
- 리트허브 사용법
- 공선옥
- collection python
- 프로그래머스 배열 회전시키기
- 프로그래머스 특정 문자 제거하기
- 리트허브 커밋
- leftJoin
- 프레젠테이션 레이어
- 프로그래머스
- 파이썬 특정 문자 제거하기
- 슈츠 자막
- 2-layered architecture
- 배열의 유사도 파이썬
- 개발자 취준
- 파이썬 컬렉션
- 리트허브 오류
- Today
- Total
기억보다 기록을
[HackerRank] Compare the Tripliets, A Very Big Sum, Diagonal Difference 본문
[HackerRank] Compare the Tripliets, A Very Big Sum, Diagonal Difference
juyeong 2023. 4. 20. 16:39[Compare the Tripliets]
Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty. ..
문제 상세 : https://www.hackerrank.com/challenges/compare-the-triplets/problem?isFullScreen=true
Compare the Triplets | HackerRank
Compare the elements in two triplets.
www.hackerrank.com
답:
def compareTriplets(a, b):
answer = [0,0]
for i in range(len(a)):
if a[i] == b[i]:
continue
elif a[i] > b[i]:
answer[0] +=1
elif a[i] < b[i]:
answer[1] +=1
return answer
더 좋은 방법이 있을 것 같은데
리스트 한줄로 한다거나 음 음 음 ...
우선 웜업 단계니까 편하게 푸는 것에 의의를 두고 좀 더 나은 아이디어를 찾아 추가하는 방향으로 하겠습니다 :)
[A Very Big Sum]
keep in mind that each elements will be larger than normal integer.. but 나에겐 파이썬 sum() 함수가 있는걸..
다른 언어는 언어가 클 때 빅오표기법 확인해봐야겠다 근데 파이썬은 .. 예.. 걍 sum 해버림..
문제: you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.
A Very Big Sum | HackerRank
Calculate the sum of the values in an array that might exceed the range of int values.
www.hackerrank.com
답:
def aVeryBigSum(ar):
return sum(ar)
[Diagonal Difference]
squared matrix에서 diagonals의 (left to right and reversal of it) 차이의 절댓값을 구하는 문제였다
한줄로 abs(sum() - sum()) return 하고 싶었는데 그건 안됐고
답은 다음과 같다
문제 상세:
답:
def diagonalDifference(arr):
n = len(arr)
sum_primary = 0
sum_secondary = 0
for i in range(n):
sum_primary += arr[i][i]
sum_secondary += arr[i][n-i-1]
return abs(sum_primary - sum_secondary)