#LeetCode
ほぼ日刊競プロ leetcode 1323. Maximum 69 Number
1323. Maximum 69 Number
You are given a positive integer num consisting only of digits 6 and 9.
Return the maximum number you can get by changing at most one digit (6 becomes 9, and 9 becomes 6).
考えた
ほぼ日刊競プロ leetcode 2. Add Two Numbers
2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two
ほぼ日刊競プロ leetcode 448. Find All Numbers Disappeared in an Array
448. Find All Numbers Disappeared in an Array
Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums
ほぼ日刊競プロ leetcode 392. Is Subsequence
392. Is Subsequence
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
A subsequence of a string is a new string that is formed from the original string by deleting
ほぼ日刊競プロ leetcode 344. Reverse String
344. Reverse String
Write a function that reverses a string. The input string is given as an array of characters s.
You must do this by modifying the input array in-place with O(1) extra memory.
考えたこ
ほぼ日刊競プロ leetcode 338. Counting Bits
338. Counting Bits
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.
考えたこと以下の3パターンを考えた.
1.2進数に
ほぼ日刊競プロ leetcode 46. Permutations
46. Permutations
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
考えたこと配列が与えられるので,順列を生成し返せばよい.pythonにはitertoolsを使えば組み合わせや順列を生成でき
ほぼ日刊競プロ leetcode 283. Move Zeroes
283. Move Zeroes
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Note that you must do this in-place without making a copy of
ほぼ日刊競プロ leetcode 136. Single Number
136. Single Number
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.
You must implement a solution with a linear runtime complexity and use on
ほぼ日刊競プロ leetcode 160. Intersection of Two Linked Lists
160. Intersection of Two Linked Lists
Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all,
ほぼ日刊競プロ leetcode 234. Palindrome Linked List
234. Palindrome Linked List
Given the head of a singly linked list, return true if it is a palindrome.
palindromeは回文を意味する.
考えたこと回文判定をしていけば良いので,回帰で連結リストをたぐっていき,中の値をリストに入れていく.最後にそのリストを逆さまにしても同じ結果が出るかを
ほぼ日刊競プロ leetcode 70. Climbing Stairs
70. Climbing Stairs
You are climbing a staircase. It takes n steps to reach the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
考えたこと0段の階段だと1パターン
ほぼ日刊競プロ leetcode 543. Diameter of Binary Tree
543. Diameter of Binary Tree
Given the root of a binary tree, return the length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any two nodes in a
ほぼ日刊競プロ leetcode 108. Convert Sorted Array to Binary Search Tree
108. Convert Sorted Array to Binary Search Tree
Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.
A height-balanced bina