Problem solve

Source https://leetcode.com/problems/plus-one/ Plus One - LeetCode Can you solve this real interview question? Plus One - You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to- leetcode.com Code /** * @param {number[]} digits * @return {number[]} */ v..
Source https://leetcode.com/problems/permutations/ Permutations - LeetCode Can you solve this real interview question? Permutations - Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1], leetcode.com Code /** * @param {number[]} nums * @return {number[][]}..
Source https://leetcode.com/problems/valid-parentheses/description/ Valid Parentheses - LeetCode Can you solve this real interview question? Valid Parentheses - Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the sam leetcode.com Code dict = { ")": "(", "]": "[..
Source https://leetcode.com/problems/reverse-integer/ Reverse Integer - LeetCode Can you solve this real interview question? Reverse Integer - Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the envir leetcode.com Code /** * @param {number} x * @return {number}..
Source https://leetcode.com/problems/3sum/ 3Sum - LeetCode Can you solve this real interview question? 3Sum - Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain du leetcode.com Code class Solution: def threeSum(self, nums: list[int]) -> list[list..
Source https://school.programmers.co.kr/learn/courses/30/lessons/77484 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Code def solution(lottos, win_nums): rank_dict = { 0: 6, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1 } zero = min(lottos.count(0), 5) rank = rank_dict[len((set(lottos) & set(win_nums)))] return [rank - zero, rank] How to solv..
Source https://school.programmers.co.kr/learn/courses/30/lessons/77485 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Code def solution(rows, columns, queries): maps = [[(x * columns) + y for y in range(1, columns + 1)] for x in range(rows)] answer = [] def iterate(maps, rotate): y = rotate[0] - 1 x = rotate[1] - 1 limit_y = rotate[..
Source https://school.programmers.co.kr/learn/courses/30/lessons/142085 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr Code import heapq def solution(n, k, enemy): heap = [] answer = 0 sum = 0 for i in enemy: heapq.heappush(heap, (-i, i)) sum += i answer += 1 if sum > n: if k: sum -= heapq.heappop(heap)[1] k -= 1 else: return answer..
Source https://leetcode.com/problems/palindrome-number/ Palindrome Number - LeetCode Can you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Ex leetcode.com Code /** * @param {number} x * @return {boolea..
Source https://leetcode.com/problems/longest-substring-without-repeating-characters/ v2.has(x))); const union = new Set([...v1, ...v2]); const complement = new Set([...v1].filter((x) => !v2.has(x))); const intersect2 = v1 && v2; const union2 = v1 || v2; console.log(intersect); // { 2, 3 } console.log(intersect2); // { 2, 3 } console.log(union); // { 1, 2, 3 } console.log(union2); // { 1, 2, 3 } ..
cslee00
'Problem solve' 카테고리의 글 목록 (2 Page)