프로그래머스 - 다음 큰 숫자

문제 설명

자연수 n이 주어졌을 때, n의 다음 큰 숫자는 다음과 같이 정의 합니다.

  • 조건 1. n의 다음 큰 숫자는 n보다 큰 자연수 입니다.
  • 조건 2. n의 다음 큰 숫자와 n은 2진수로 변환했을 때 1의 갯수가 같습니다.
  • 조건 3. n의 다음 큰 숫자는 조건 1, 2를 만족하는 수 중 가장 작은 수 입니다.

예를 들어서 78(1001110)의 다음 큰 숫자는 83(1010011)입니다.

자연수 n이 매개변수로 주어질 때, n의 다음 큰 숫자를 return 하는 solution 함수를 완성해주세요.


Lisa's Workbook

Lisa just got a new math workbook. A workbook contains exercise problems, grouped into chapters. Lisa believes a problem to be special if its index (within a chapter) is the same as the page number where it’s located. The format of Lisa’s book is as follows:

  • There are n chapters in Lisa’s workbook, numbered from 1 to n.
  • The chapter has arr[i] problems, numbered from 1 to arr[i].
  • Each page can hold up to k problems. Only a chapter’s last page of exercises may contain fewer than k problems.
  • Each new chapter starts on a new page, so a page will never contain problems from more than one chapter.
  • The page number indexing starts at 1.

Service Lane

Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any risks. Luckily, a service lane runs parallel to the highway. The service lane varies in width along its length.

You will be given an array of widths at points along the road (indices), then a list of the indices of entry and exit points. Considering each entry and exit point pair, calculate the maximum size vehicle that can travel that segment of the service lane safely.

For example, there are n = 4 measurements yielding width = [2, 3, 2, 1]. If our entry index, i = 1 and our exit, j = 2, there are two segment widths of 2 and 3 respectively. The widest vehicle that can fit through both is 2. If i = 2 and j = 4, our widths are [3, 2, 1] which limits vehicle width to 1.


Chocolate Feast

Little Bobby loves chocolate. He frequently goes to his favorite 5 & 10 store, Penny Auntie, to buy them. They are having a promotion at Penny Auntie. If Bobby saves enough wrappers, he can turn them in for a free chocolate.

For example, Bobby has n = 15 to spend on bars of chocolate that cost c = 3 each. He can turn in m = 2 wrappers to receive another bar. Initially, he buys 5 bars and has 5 wrappers after eating them. He turns in 4 of them, leaving him with 1, for 2 more bars. After eating those two, he has 3 wrappers, turns in 2 leaving him with 1 wrapper and his new bar. Once he eats that one, he has 2 wrappers and turns them in for another bar. After eating that one, he only has 1 wrapper, and his feast ends. Overall, he has eaten 5 + 2 + 1 + 2 = 9 bars.


NOMADCODERS ReactJS Challenge - 시작하기

2019. 8. 26 ~ 2019. 9. 9

노마드 코더의 초보를 위한 React JS 강좌는 이미 한번 완강을 했지만 항상 강의만 듣고 기록을 남기지 않아서, 나중에 필요한경우 다시 검색을 하거나 그 부분의 강의를 찾아 보는 경우가 많았던것 같습니다.
다시한번 강의를 들으면서 필요한 부분에 대한 내용을 덧붙여 강의노트를 만들어 보고자 기록을 남기기 시작했습니다.
이번 챌린지를 통해서 기록을 남기는 습관을 갖을 수 있게 되기를 바랍니다.


Clone Coding for ReactJS Challenge

노마드코더 초보를 위한 React JS
ReactJS Challenge by Nomadcoders


챌린지 관련 내용의 정답 유출 금지 내용을 전달 받아 포스팅 내 Homework 내용을 삭제합니다.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×