オットセイの経営日誌

データサイエンス系ベンチャーを経営してます。経営のこと、趣味のことつぶやきます。

2020-01-01から1ヶ月間の記事一覧

LeetCode / Contains Duplicate, Contains Duplicate Ⅱ

明日から海外旅行で浮き足立っていますが、リストから重複判定する問題シリーズを解きます。 https://leetcode.com/problems/contains-duplicate/ Given an array of integers, find if the array contains any duplicates. Your function should return tru…

LeetCode / Reversed Linked List

https://leetcode.com/problems/reverse-linked-list/ Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL 1つのLinked Listをsortして逆順にする問題。 解法1 Iterativeな解法。 # Definition for singly-lin…

LeetCode / Isomorphic Strings

https://leetcode.com/problems/isomorphic-strings/ Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with…

LeetCode / Count Primes

https://leetcode.com/problems/count-primes/ Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. 与えられた値より小さい…

LeetCode / Remove Linked List Elements

https://leetcode.com/problems/remove-linked-list-elements/ Remove all elements from a linked list of integers that have value val. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 これがlistだったりsetだったら問題にもなら…

LeetCode / Happy Number

https://leetcode.com/problems/happy-number/ Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squar…

LeetCode / House Robber

プログラミングの技術ではなく、高校(中学?)数学の知識を頭の片隅から引っ張り出す必要がある問題。 https://leetcode.com/problems/house-robber/ You are a professional robber planning to rob houses along a street. Each house has a certain amou…

LeetCode / Find the Difference

シンプルな問題ですが、dictionary使ったり、Counter使ったり、アスキーコード使ったり、ビット演算使ったりと、解法が多岐にわたる良問かも。 https://leetcode.com/problems/find-the-difference/ Given two strings s and t which consist of only lowerc…

LeetCode / First Unique Character in a String

今日は、いくら計算量を頑張って削減してもPythonの超えられない壁があるよ、ということを身を以て伝えてくれる問題です。 https://leetcode.com/problems/first-unique-character-in-a-string/ Given a string, find the first non-repeating character in …

フレームワークに則って昨年の振り返りをしてみた。

皆様、あけましておめでとうございます。 本年もよろしくお願い申し上げます。 年末年始は、妻と自分の実家廻りをしておりました。 行き先は長野と富山ということで、暖かく迎えていただきながら、中部・北陸の美味しい酒・魚と、普段全く見ない分だけより面…