# Algorithm

1309. Decrypt String from Alphabet to Integer Mapping

https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping/

Given a string `s` formed by digits (`'0'` - `'9'`) and `'#'` . We want to map `s` to English lowercase characters as follows:

• Characters (`'a'` to `'i')` are represented by (`'1'` to `'9'`) respectively.
• Characters (`'j'` to `'z')` are represented by (`'10#'` to `'26#'`) respectively.

Return the string formed after mapping.

It’s guaranteed that a unique mapping will always exist.

Example 1:

`Input: s = "10#11#12"Output: "jkab"Explanation: "j" -> "10#" , "k" -> "11#" , "a" -> "1" , "b" -> "2".`

Example 2:

`Input: s = "1326#"Output: "acz"`

Example 3:

`Input: s = "25#"Output: "y"`

Example 4:

`Input: s = "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#"Output: "abcdefghijklmnopqrstuvwxyz"`

Constraints:

• `1 <= s.length <= 1000`
• `s[i]` only contains digits letters (`'0'`-`'9'`) and `'#'` letter.
• `s` will be valid string such that mapping is always possible.

1436. Destination City

https://leetcode.com/problems/destination-city/

You are given the array `paths`, where `paths[i] = [cityAi, cityBi]` means there exists a direct path going from `cityAi` to `cityBi`. Return the destination city, that is, the city without any path outgoing to another city.

It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.

Example 1:

`Input: paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]]Output: "Sao Paulo" Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo".`

Example 2:

`Input: paths = [["B","C"],["D","B"],["C","A"]]Output: "A"Explanation: All possible trips are: "D" -> "B" -> "C" -> "A". "B" -> "C" -> "A". "C" -> "A". "A". Clearly the destination city is "A".`

Example 3:

`Input: paths = [["A","Z"]]Output: "Z"`

Constraints:

• `1 <= paths.length <= 100`
• `paths[i].length == 2`
• `1 <= cityAi.length, cityBi.length <= 10`
• `cityAi != cityBi`
• All strings consist of lowercase and uppercase English letters and the space character.

1450. Number of Students Doing Homework at a Given Time

https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time/

Given two integer arrays `startTime` and `endTime` and given an integer `queryTime`.

The `ith` student started doing their homework at the time `startTime[i]` and finished it at time `endTime[i]`.

Return the number of students doing their homework at time `queryTime`. More formally, return the number of students where `queryTime` lays in the interval `[startTime[i], endTime[i]]` inclusive.

Example 1:

`Input: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4Output: 1Explanation: We have 3 students where:The first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.The second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.The third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.`

Example 2:

`Input: startTime = [4], endTime = [4], queryTime = 4Output: 1Explanation: The only student was doing their homework at the queryTime.`

Example 3:

`Input: startTime = [4], endTime = [4], queryTime = 5Output: 0`

Example 4:

`Input: startTime = [1,1,1,1], endTime = [1,3,2,4], queryTime = 7Output: 0`

Example 5:

`Input: startTime = [9,8,7,6,5,4,3,2,1], endTime = [10,10,10,10,10,10,10,10,10], queryTime = 5Output: 5`

Constraints:

• `startTime.length == endTime.length`
• `1 <= startTime.length <= 100`
• `1 <= startTime[i] <= endTime[i] <= 1000`
• `1 <= queryTime <= 1000`

1381. Design a Stack With Increment Operation

Design a stack which supports the following operations.

Implement the `CustomStack` class:

• `CustomStack(int maxSize)` Initializes the object with `maxSize` which is the maximum number of elements in the stack or do nothing if the stack reached the `maxSize`.
• `void push(int x)` Adds `x` to the top of the stack if the stack hasn't reached the `maxSize`.
• `int pop()` Pops and returns the top of stack or -1 if the stack is empty.
• `void inc(int k, int val)` Increments the bottom `k` elements of the stack by `val`. If there are less than `k` elements in the stack, just increment all the elements in the stack.

Example 1:

`Input["CustomStack","push","push","pop","push","push","push","increment","increment","pop","pop","pop","pop"][[3],[1],[2],[],[2],[3],[4],[5,100],[2,100],[],[],[],[]]Output[null,null,null,2,null,null,null,null,null,103,202,201,-1]ExplanationCustomStack customStack = new CustomStack(3); // Stack is Empty []customStack.push(1);                          // stack becomes [1]customStack.push(2);                          // stack becomes [1, 2]customStack.pop();                            // return 2 --> Return top of the stack 2, stack becomes [1]customStack.push(2);                          // stack becomes [1, 2]customStack.push(3);                          // stack becomes [1, 2, 3]customStack.push(4);                          // stack still [1, 2, 3], Don't add another elements as size is 4customStack.increment(5, 100);                // stack becomes [101, 102, 103]customStack.increment(2, 100);                // stack becomes [201, 202, 103]customStack.pop();                            // return 103 --> Return top of the stack 103, stack becomes [201, 202]customStack.pop();                            // return 202 --> Return top of the stack 102, stack becomes [201]customStack.pop();                            // return 201 --> Return top of the stack 101, stack becomes []customStack.pop();                            // return -1 --> Stack is empty return -1.`

Constraints:

• `1 <= maxSize <= 1000`
• `1 <= x <= 1000`
• `1 <= k <= 1000`
• `0 <= val <= 100`
• At most `1000` calls will be made to each method of `increment`, `push` and `pop` each separately.

# 문제

아래와 같이 정의된 피보나치 수열 중 n번째 항의 수를 리턴해야 합니다.

• 0번째 피보나치 수는 0이고, 1번째 피보나치 수는 1입니다. 그 다음 2번째 피보나치 수부터는 바로 직전의 두 피보나치 수의 합으로 정의합니다.
• 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …

# 인자 1 : n

• `number` 타입의 n (n은 0 이상의 정수)

# 출력

• `number` 타입을 리턴해야합니다.

# 주의사항

• fibonacci 함수는 재귀함수 형태로 작성해야 합니다.

# 입출력 예시

`let output = fibonacci(0);console.log(output); // --> 0output = fibonacci(1);console.log(output); // --> 1output = fibonacci(5);console.log(output); // --> 5output = fibonacci(9);console.log(output); // --> 34`

• 재귀함수의 형태를 유지한 채, 메모이제이션(memoization)을 적용하여 Advanced 테스트 케이스를 통과해 보세요.

--

--

## More from Joo Hee Paige Kim

Consistency achieves everything https://github.com/paigekim29

Love podcasts or audiobooks? Learn on the go with our new app.