inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

1068번: 트리

미해결

파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)

제가 다음과 같이 코드를 작성했는데, 100%까지 가다가 틀립니다.. 어떤게 문제일까요? 반례를 제시해주실 수 있나요? 감사합니다. https://www.acmicpc.net/problem/1068 import sys input = sys.stdin.readline n = int(input()) g = list(map(int, input().split())) m = int(input()) cnt = 0 def DFS(x): g[x] = -1 for i in range(n): if g[i] == x: DFS(i) DFS(m) for i in range(n): if g[i] != -1 and i not in g: cnt += 1 print(cnt)

  • python
  • 코딩-테스트
  • 코테 준비 같이 해요!
이도열 댓글 1 좋아요 1 조회수 378

안녕하세요 리뷰복습하다가, 발견했습니다

미해결

파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)

최근에 다시 자바스크립트로 돌리면서, 기존에 파이썬으로 했던 것들 다시 모두 자바스크립트로 풀어보면서 문제 풀어보니, 발견했습니다. 이거 첫번째 가정을, 그리디로 접근하면 해결 안되는 문제인것같습니다. 이후 가정들은 당연히 그리디 관념으로 최적값 찾을 수 있는데, 첫번째 가정부터 그리디로 접근하면 해결되는 문제가 아니라서 어긋나기때문에, 그리디관념이 통하지 않는 문제인것같습니다. 완전탐색해버리거나, 시간 더 줄이려면 백트래킹 가지치기 해야하는 문제인것같습니다. 입력입니다! 7 172 67 183 65 179 61 178 62 177 63 170 72 181 60 기존 풀이(무조건 183선발) 가 내주는 답 : 3 감독 현수가 원할 것 같은 답 : 6 그리디로 가장 키 큰 사람 무조건 선발하는 과정이 풀이에서 오류인것같습니다. 183 선발 가정하고 cnt 값 구하고, 그다음 181 선발 가정하고 cnt값 구하고, 쭉 다음 순으로 선발 가정하고 cnt값 구하는데, 만약 어떤 사람 선발 가정하고 cnt값 구하는데 남은 사람 수 다 합해도 기존 Max cnt보다 적을 경우, 백트레킹 가지치기로 break 혹은 return 끊어버리는게 맞는것같습니다. 풀이1. 이중포문 const input = require("fs") .readFileSync("input.txt") .toString() .trim() .split("\n"); const n = parseInt(input[0]); const arr = Array.from(Array(5), () => []); for (let i = 0; i < n; i++) { arr[i] = Array.from(input[i + 1].trim().split(" ")).map((v) => parseInt(v)); } function solution(n, arr) { arr.sort((a, b) => b[0] - a[0]); let cnt = 0; let largest = 0; let res = 0; for (let i = 0; i < n; i++) { largest = arr[i][1]; cnt += 1; if (res >= n - i) { break; } for (let j = i + 1; j < n; j++) { if (arr[j][1] > largest) { largest = arr[j][1]; cnt += 1; } } res = Math.max(res, cnt); cnt = 0; } console.log(res); } solution(n, arr); 풀이2. DFS const input = require("fs") .readFileSync("input.txt") .toString() .trim() .split("\n"); const n = parseInt(input[0]); const arr = Array.from(Array(5), () => []); for (let i = 0; i < n; i++) { arr[i] = Array.from(input[i + 1].trim().split(" ")).map((v) => parseInt(v)); } let cnt = 0; let res = 0; //const list = []; function DFS(s, weight) { if (s < 0) return; if (cnt + n - s <= res) { cnt -= 1; s -= 1; return; } for (let i = s; i < n; i++) { if (arr[i][1] > weight) { cnt += 1; //list.push(arr[i][1]); DFS(i + 1, arr[i][1]); //list.pop(); } } res = Math.max(res, cnt); //console.log(list); cnt -= 1; } function solution(n, arr) { arr.sort((a, b) => b[0] - a[0]); DFS(0, 0); console.log(res); } solution(n, arr);

  • 코딩-테스트
  • python
  • 코테 준비 같이 해요!
ncprog1 댓글 2 좋아요 1 조회수 456

로드맵상 다음강의? 크롤링? 퀀트1?

해결됨

문과생도, 비전공자도, 누구나 배울 수 있는 파이썬(Python)!

안녕하세요.. 멋지고 깔끔한 강의 덕분에 2주만에 완강했습니다! 좋은 강의 준비해주셔서 감사합니다. 로드맵상 다음강의가 퀀트part1 으로 되어 있는데, 크롤링을 모르고 가도 상관이 없을까요? 아니면 크롤링 강의 먼저 듣고 가는게 나을까요?

  • python
wk 댓글 1 좋아요 0 조회수 272

jsconfig 오류 질문입니다!

해결됨

파이썬/장고 웹서비스 개발 완벽 가이드 with 리액트

{ "compilerOptions": { "baseUrl": "src" }, "include": ["src"] } keonhongkoo@keonhongui-MacBookAir frontend % yarn start yarn run v1.22.19 $ react-scripts start node:internal/modules/cjs/loader:1325 throw err; ^ SyntaxError: /Users/keonhongkoo/Desktop/instagram/frontend/jsconfig.json: Unexpected token / in JSON at position 75 at parse (<anonymous>) at Module._extensions..json (node:internal/modules/cjs/loader:1322:39) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at getModules (/Users/keonhongkoo/Desktop/instagram/frontend/node_modules/react-scripts/config/modules.js:126:14) at Object.<anonymous> (/Users/keonhongkoo/Desktop/instagram/frontend/node_modules/react-scripts/config/modules.js:142:18) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) Node.js v18.14.1 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 이렇게 결과가 출력되는데 해결책이 안보이네요... vscode도 재시작해봤습니다ㅠ

  • docker
  • python
  • react
  • django
꺼넝 댓글 1 좋아요 0 조회수 813

pin brute force 시 앱 종료

미해결

프리다(Frida)를 이용한 안드로이드 앱 모의해킹

공기계로 실습 진행하고 있습니다. pin 번호 brute force 진행 시 앱이 중지되었다고 뜨면서 앱이 종료됩니다. 코드는 강사님과 동일한데, 안되는 이유가 있을까요?

  • frida
  • 모의해킹
  • android
  • 모의해킹
vvi 댓글 1 좋아요 0 조회수 574

질문드립니다.

미해결

남박사의 파이썬 기초부터 실전 100% 활용

사용자 입력 예외처리를 하고 있는데, 1)문자 입력 시 오류 2)3자리 숫자가 아닐 경우 오류 다음과 같이 코드를 짰는데 1)의 경우 except 부분에서 "입력 오류"를 출력하지만 2)의 경우 "입력오류"가 출력되지 않고 그냥 재입력하게 되네요. 혹시 이유를 알 수 있나요? 또한 문자 입력 시 "숫자만 입력 가능합니다"를 출력 두자리수 입력 시 "세 자리 수를 입력하세요"를 출력 하도록 하려면 코드를 어떻게 수정해야 할까요? 감사합니다.! #세 자리 숫자만 입력할 수 있게 하는 함수 def input_check(msg, casting = int): while True: try: num = input(msg) # 사용자 입력 num_str = str(num) #맨 앞의 수가 0일경우 0이 잘려버리기 때문에 str을 따로 저장 if(casting(num) and len(num) == 3): return num_str except: print("입력 오류") continue

  • 웹-크롤링
  • 웹-크롤링
  • python
Poki 댓글 2 좋아요 1 조회수 405

아나콘다 버전 관련 문의 드립니다~!

미해결

파이썬/장고 웹서비스 개발 완벽 가이드 with 리액트

안녕하세요~! 아나콘다를 설치하면서 두가지 정도 질문이 있습니다 1) 2023.02.22날짜로 아나콘다 최신판을 설치하는데 그림과 같이 옵션사항에 환경변수 체크가 되지 않습니다 ㅠㅠ 업데이트 되면서 바뀐것인지 아나콘다 최신판에서 이 옵션을 선택하지 않아도 괜찮을까요?? 2) 2023.02.22날짜로 아나콘다 최신판에서는 파이썬 버전이 3.9버전인데 파이썬 공식버전으로는 3.11까지 배포가 되었습니다 버전 차이가 많이 나도 아나콘다를 설치하는게 사용에 더 편리할까요??

  • python
  • django
  • docker
  • react
서성길 댓글 3 좋아요 0 조회수 1297

오류가 생성되는데 왜 생기는지 궁금해서 질문드립니다

미해결

[중급편] 코인 가격 모니터링 앱 제작 (Android Kotlin)

E/RecyclerView: No adapter attached; skipping layout E/RecyclerView: No adapter attached; skipping layout coinListFragment 에서 생성되는 오류라고 생해서 관련된 부분을 수정해보았으나 계속해서 오류가 생성되서 왜 생기는걸까? 궁금해서 질문드립니다. 오류와 관계없이 화면에 리사이클러뷰는 잘 나오기때문에 넘어가도 상관없겠다 싶지만서도 왜 저런 오류가 생기는지 궁금해서 질문 합니다. 처음에는 XML 상에서도 layoutManager 를 지정해줘야 하나 싶어서 했으나 나타났고, 다음으로는 context 관련 문제인가 싶어서 해당하는 부분을 수정하다가 오히려 더 오류가 발생하였습니다...ㅋㅋㅋ 기능에는 문제가 없기 때문에 넘어가도 괜찮지만 순수하게 궁금해서 질문합니다. 아니면 혹시, coinListFragment 쪽의 RecyclerView 가 아닌, Intro 에서 좋아하는 코인을 만들때 의 오류메시지 일까요?

  • android
  • kotlin
ancan Eil 댓글 2 좋아요 0 조회수 546

FireBase 익명로그인 실패

미해결

[왕초보편] 앱 8개를 만들면서 배우는 안드로이드 코틀린(Android Kotlin)

강사님 말씀대로 했는데 익명 로그인 부분에서 else(익명로그인 실패)부분이 뜨네요

  • firebase
  • android
  • kotlin
주식회사에어텍 댓글 2 좋아요 1 조회수 759

봉우리 - 가장자리 0으로 채우기

해결됨

파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)

이렇게 (N+2)*(N+2) list를 만들고 안에다가 복사해서 붙여넣어버리는 방법은 별로인가요? N = int(input()) input_list = [list(map(int, input().split())) for _ in range(N)] n_list = [[0] * (N + 2) for _ in range(N + 2)] for i in range(N): for j in range(N): n_list[i + 1][j + 1] = input_list[i][j]

  • 코테 준비 같이 해요!
  • 코딩-테스트
  • python
Jiyoung Kang 댓글 2 좋아요 0 조회수 476

에러코드

미해결

[왕초보편] 앱 8개를 만들면서 배우는 안드로이드 코틀린(Android Kotlin)

Run 돌리면 자꾸 에러가 떠서 그냥 아무 코드 입력없이 새 프로젝트를 만들어 돌려도 다음과 같은 에러코드가 뜹니다. 원인이 무엇일까요?? 6 issues were found when checking AAR metadata: 1. Dependency 'androidx.appcompat:appcompat-resources:1.6.1' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs. :app is currently compiled against android-32. Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on). 2. Dependency 'androidx.appcompat:appcompat:1.6.1' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs. :app is currently compiled against android-32. Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on). 3. Dependency 'androidx.activity:activity:1.6.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs. :app is currently compiled against android-32. Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on). 4. Dependency 'androidx.core:core:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs. :app is currently compiled against android-32. Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on). 5. Dependency 'androidx.core:core-ktx:1.9.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs. :app is currently compiled against android-32. Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on). 6. Dependency 'androidx.annotation:annotation-experimental:1.3.0' requires libraries and applications that depend on it to compile against version 33 or later of the Android APIs. :app is currently compiled against android-32. Recommended action: Update this project to use a newer compileSdkVersion of at least 33, for example 33. Note that updating a library or application's compileSdkVersion (which allows newer APIs to be used) can be done separately from updating targetSdkVersion (which opts the app in to new runtime behavior) and minSdkVersion (which determines which devices the app can be installed on).

  • android
  • kotlin
  • firebase
D.H.LEE 댓글 2 좋아요 0 조회수 5707

리미트 타임에러

미해결

자바(Java) 알고리즘 문제풀이 입문: 코딩테스트 대비

소수 개수 구하기 문제 언어 : 파이썬 내용: 제가 작성한 하위 코드 for문 두 개 돌렸을뿐인데 리미트 타임에러가 뜹니다.. 구글링 해서 emurate함수 써서 푼 문제는 정답이라고 뜹니다. 난이도 초급에 emurate함수 방식으로 써서 풀라는 의도는 아니라고 판단되어 문의 드립니다. 아래 코드가 에러인지, 제가 잘 못하고 있는지 궁금합니다. (입사 전에는 자바로 면접 보고 들어갔는데 입사 한 회사에서 사용하는 언어는 파이썬이라서 파이썬으로 코테 풀고 있는점도 참고해서 피드백 부탁드립니다) received_data = int(input()) list = [] for i in range(2,received_data+1): list.append(0) for i in range(2,received_data+1): if list[i-2]==0: for j in range(2,received_data+1): if j>i and j%i==0: list[j-2]=1 print(list.count(0))

  • java
  • 코딩-테스트
  • 코테 준비 같이 해요!
  • python
xorwn12345 댓글 1 좋아요 0 조회수 279

안녕하세요. 용어에 대해 질문이 있어 글 남깁니다.

미해결

냉동코더의 알기 쉬운 Modern Android Development 입문

안녕하세요. 강의 잘듣고 있습니다. 다만, 제가 이 강의부터 시작해서 그런지 용어에 대한 개념이 헷갈립니다. util 디렉토리와 source.kt 파일의 역할은 정확히 무엇인가요? util 디렉토리에 들어가는 파일들의 내용은 무엇이고, DataSource의 역할이 무엇인지 궁금합니다 ! 감사합니다..

  • android
  • 아키텍처
  • architecture
  • kotlin
  • jetpack
댓글 2 좋아요 0 조회수 423

Exception has occurred: SSLError 이런 에러가 발생합니다.

미해결

[신규 개정판] 이것이 진짜 크롤링이다 - 기본편

이 강의에서 에러가 발생했습니다. 소스코드는 다음과 같습니다. import requests from bs4 import BeautifulSoup url = "https://www.naver.com/" response = requests.get(url) # 에러 발생한 부분 html = response.text soup = BeautifulSoup(html, 'html.parser') word = soup.select_one("#NM_set_home_btn") print(word.text) 위 코드중 response = requests.get(url) 위 부분에서 에러가 발생했습니다. [ 에러 내용 ] Max retries exceeded with url:강의에서 접속한 url 이런 에러가 나오고 Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available. 뒤에 이런 문장이 나옵니다. 에러 해결 방법은 무었인가요? [ 에러 전체 내용 ] 에러의 전체 내용은 다음과 같습니다. Exception has occurred: SSLError HTTPSConnectionPool(host='search.naver.com', port=443): Max retries exceeded with url: /search.naver?where=news&sm=tab_jum&query=%EC%82%BC%EC%84%B1%EC%A0%84%EC%9E%90 (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available. During handling of the above exception, another exception occurred: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='search.naver.com', port=443): Max retries exceeded with url: /search.naver?where=news&sm=tab_jum&query=%EC%82%BC%EC%84%B1%EC%A0%84%EC%9E%90 (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) During handling of the above exception, another exception occurred: File "D:\crawling\05. 뉴스 제목과 링크 가져오기.py", line 4, in <module> response = requests.get("https://search.naver.com/search.naver?where=news&sm=tab_jum&query=%EC%82%BC%EC%84%B1%EC%A0%84%EC%9E%90") requests.exceptions.SSLError: HTTPSConnectionPool(host='search.naver.com', port=443): Max retries exceeded with url: /search.naver?where=news&sm=tab_jum&query=%EC%82%BC%EC%84%B1%EC%A0%84%EC%9E%90 (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

  • 웹-크롤링
  • 웹-크롤링
  • python
새벽별 댓글 1 좋아요 0 조회수 2025

함수 컴포넌트와 필수 Hook에서 setValue({value1:10}) 관련 질문이요!

해결됨

파이썬/장고 웹서비스 개발 완벽 가이드 with 리액트

function App2() { const [value1, setValue1] = useState(0); const [value2, setValue2] = useState(0); const [value, setValue] = useState({ value1: 0, value2: 0 }); const onClick = () => { setValue({ value1: 10 }); }; return ( <div> Hello App2 <hr /> {JSON.stringify(value1)} {JSON.stringify(value2)} {JSON.stringify(value.value1)} <button onClick={onClick}>클릭</button> </div> ); } export default App2; 여기서 onClick을 수행할때 왜 value.value1의 값이 변경되는 건가요?? 첫번째에 useState(0)으로 만든 value1은 어떻게 해야 값의 변경이 되는거죠??

  • react
  • python
  • django
  • docker
꺼넝 댓글 1 좋아요 0 조회수 400

abe-all.jar 파일은 어디서 다운받나요??

미해결

안드로이드 모바일 앱 모의해킹과 시큐어코딩

abe-all.jar 어디에서 받을 수 있죠?...

  • android
  • 모의해킹
  • 모의해킹
꾸해 댓글 1 좋아요 0 조회수 1909

Button을 사용하는 경우와 TextView를 사용하는 경우에 대해 차이가 궁금합니다.

해결됨

[중급편] 코인 가격 모니터링 앱 제작 (Android Kotlin)

안녕하세요 강의 막바지를 향해 달려가고 있던 중 궁금한 점이 있습니다. SelectActivity에서 다음 MainActivity로 넘어가기 위해 onClick 이벤트를 TextView를 통해 처리하는 것을 보았습니다. 그런데 SettingActivity에서는 Button을 생성하는 것을 보고 TextView를 통해 클릭 이벤트를 처리하는 것과 Button을 통해 이벤트를 처리하는 것에 대한 차이가 있는지 궁금합니다. 혹은 개발자님만의 상황에 따른 사용 기준이 따로 있나요?? 유익한 강의 너무 잘 듣고 있습니다. 감사합니다

  • kotlin
  • android
  • button
후후후 댓글 1 좋아요 0 조회수 664

제발 도와주세요ㅠ

미해결

[신규 개정판] 이것이 진짜 크롤링이다 - 기본편

C:\coding\py>C:/Users/taehw/AppData/Local/Programs/Python/Python311/python.exe c:/coding/py/증권.py Traceback (most recent call last): File "c:\coding\py\증권.py", line 2, in <module> from bs4 import BeautifulSoup ImportError: cannot import name 'BeautifulSoup' from 'bs4' (C:\Users\taehw\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\__init__.py) 이렇게 오류 문자가 떠요!코드는 이렇게 썻어요! import requests from bs4 import BeautifulSoup # 종목 코드 리스트 codes = [ '035420', '088980', '005930', '035720' ] for code in codes: url = f"https://finance.naver.com/item/sise.naver?code={code}" response = requests.get(url) html = response.text soup = BeautifulSoup(html, 'html.parser') price = soup.select_one("#_nowVal").text price = price.replace(',', '') print(price)

  • 웹-크롤링
  • 웹-크롤링
  • import
  • python
  • 애러
holy210 댓글 2 좋아요 0 조회수 495

repository 를 거쳐서 Api 를 가져오는 이유

해결됨

[중급편] 코인 가격 모니터링 앱 제작 (Android Kotlin)

SelectViewModel 에서 Api를 바로 호출하지 않고 repository 거쳐서 가는게 관리하기 편해서라고 하셨는데 이해가 잘 가지 않아서요.. 바로 호출하면 어떤 불편한 점이 있나요?

  • kotlin
  • android
뿌지징 댓글 1 좋아요 0 조회수 449

인기 태그

인프런 TOP Writers

주간 인기글