サンダーボルト

相手モンスターを全て破壊する。

Java

LeetCode Study : 160. Intersection of Two Linked Lists

問題 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: Example 1: Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skip…

LeetCode Study : 141. Linked List Cycle

問題 Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there…

LeetCode Study : 136. Single Number

問題 Given a non-empty array of integers, every element appears twice except for one. Find that single one. Example 1: Input: [2,2,1] Output: 1 Example 2: Input: [4,1,2,1,2] Output: 4 https://leetcode.com/problems/single-number/ Note: Your…

LeetCode Study : 122. Best Time to Buy and Sell Stock II

問題 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock m…

LeetCode Study : 121. Best Time to Buy and Sell Stock

問題 Say you have an array for which the element is the price of a given stock on day . If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum…

LeetCode Study : 118. Pascal's Triangle

問題 Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. Example: Input: 5 Output: [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] https://leetcode.com/problems/pascals-triangle/ 自分の解答 public List<List<Integer>> g</list<integer>…

LeetCode Study : 104. Maximum Depth of Binary Tree

問題 Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. Example 1: Given binary tree [3,9…

LeetCode Study : 101. Symmetric Tree

問題 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: Example 1: 1 / \ 2 2 / \ / \ 3 4 4 3 Example 2: 1 / \ 2 2 \ \ 3 3 https://leetc…

LeetCode Study : 100. Same Tree

問題 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example 1: Input: 1 1 / \ / \ 2 3 2 3 [1,2,3…

LeetCode Study : 83. Remove Duplicates from Sorted List

問題 Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Input: 1->1->2 Output: 1->2 Example 2: Input: 1->1->2->3->3 Output: 1->2->3 https://leetcode.com/problems/remove-duplicates-from-sor…

LeetCode Study : 70. Climbing Stairs

問題 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2 Output…

LeetCode Study : 27. Remove Element

問題 Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with extra memory. The o…

LeetCode Study : 26. Remove Duplicates from Sorted Array

問題 Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(…

LeetCode Study : 21. Merge Two Sorted Lists

問題 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 https://leetcode.com/problems/merge…

LeetCode Study : 20. Valid Parentheses

問題 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be close…

LeetCode Study : 14. Longest Common Prefix

問題 Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","raceca…

LeetCode Study : 9. Palindrome Number

問題 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -12…

LeetCode Study : 7. Reverse Integer

問題 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 https://leetcode.com/problems/reverse-integer/ Note: Assume we are dea…

LeetCode Study : 1. Two Sum

問題 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums …