Cindy's Blog

アマゾンで働いているエンジニアの日常

LeetCode 283. Move Zeroes

Follow up: Could you minimize the total number of operations done? https://leetcode.com/problems/move-zeroes/ //firstZeroIndex -> z // z: -1 // i //[1,3,12,0,0] //when nums[i] = 0 //if z = -1, then z = i //else //if z != -1 (had zero in fr…

LeetCode 200. Number of Islands

UnionFind island count direction https://leetcode.com/problems/number-of-islands/ class Solution { public int numIslands(char[][] grid) { int rows = grid.length; int cols = grid[0].length; int countIslands = 0; int[][] directions = {{0, 1}…

LeetCode 392. Is Subsequence

Easy question https://leetcode.com/problems/is-subsequence/ class Solution { public boolean isSubsequence(String s, String t) { int sIndex = 0; int tIndex = 0; while (sIndex < s.length() && tIndex < t.length()){ //"abc" // s //"ahbcgd" // …

LeetCode 20. Valid Parentheses

Considering with following cases "]" "{[}]" class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); for (int i = 0; i < s.length(); i++){ char c = s.charAt(i); if (c == '(' || c == '[' || c == '{'){ stack.push(c); </character>…

LeetCode 967. Numbers With Same Consecutive Differences

interestring question. The order of calculation is very important. class Solution { public int[] numsSameConsecDiff(int n, int k) { //10 ^ n => max 10^9.. List<Integer> answer = new ArrayList<>(); for (int lastDigit = 1; lastDigit <= 9; lastDigit++</integer>…

LeetCode 213. House Robber II

Very interesting question 0 ~ n - 2 また 1 ~ n -1 に2つに分けることを思いつかなかったな。 class Solution { public int rob(int[] nums) { int n = nums.length; if (n <= 3){ int max = 0; for (int i = 0; i < n; i++){ max = Math.max(nums[i], ma…

LeetCode 605. Can Place Flowers

https://leetcode.com/problems/can-place-flowers/ class Solution { public boolean canPlaceFlowers(int[] flowerbed, int n) { //max: 0 adjacent 1 //dont create like this: [1, 0, 0, 1, 0, 0, 1] and do like this [1,0,1,0,0,0,1], then we can put…

LeetCode 22. Generate Parentheses

https://leetcode.com/problems/generate-parentheses/ 問題を分析する、可能な範囲でオーダーを減らす class Solution { public List<String> generateParenthesis(int n) { //1 -> "()" //2 -> "(())", "()()" //3 -> "()()()", "(())()", "()(())", "((()))", "((</string>…

LeetCode 39 Combination Sum

https://leetcode.com/problems/combination-sum/ class Solution { public List<List<Integer>> combinationSum(int[] candidates, int target) { //pick one element unlimited times => make up sum equals to target //broute force find target List<List<Integer>> answer = new Ar</list<integer></list<integer>…

LeetCode 78 Subsets

Select and not game //select or not game! //if nums.length = n //then you have 2n options //[1,2,3] => 23 = 8 sets class Solution { public List<List<Integer>> subsets(int[] nums) { //select or not select game! //if nums.length = n //then you have 2^n op</list<integer>…

LeetCode 46. permutation

https://leetcode.com/problems/permutations/submissions/ find first element game ! //[1,2,3] // 1 -> 2 -> 3 // -> 3 -> 2 // visited or not visited? // 2 -> 3 -> 1 // 1 -> 3 // 3 -> ... class Solution { public List<List<Integer>> permute(int[] nums) { List<List<Integer></list<integer></list<integer>…

「1日5分からの断捨離」の読書記録

書籍との出会い 引越し作業により自分のものが多いなと感じたため、コツよく整理したいと思いました。 ちょうど新宿の紀伊國屋書店でおすすめコーナーにあったため購入しました。 全体のあらすじ 基本的に、家のものを「扱い方」をわかりやすく説明くれまし…

「なぜか話しかけたくなる人、ならない人」の読書感

書籍との出会い 渋谷の書店で本書を読んでみたら利用できるような内容だったので購入しました。読みたい動機は、4月から社会に出て、新社会人になるため、まずは好印象を残したいと思います。学生時代では、他人に心が開いていなかったことに気付き、状況を…

既卒の就職心得(2020年)

背景 2020年3月修士課程終わることで、元々は去年から就職活動をすべきだったのですが、修士論文やスケージュールの噛み合いが悪く、また元々インターンしていた会社との話がうまくいかず、修士課程が終わる直前、つまり2月下旬から就職活動を始めました。 …

投資の初心者が「めちゃくちゃ売れてる株の雑誌Zaiが作った株入門」を読んだ感想とまとめ

簡単な紹介 最近貯金できるようになり、なんとなく投資したいと思うのでこの本を購入しました。この本は2013年発行され、今年2019年は第17刷でして、内容は少し古くなってきています。しかし、おかげでその時点の株を確認できて(成長できた株はほとんど)、…

プログラマが知るべき97のこと (日本語) の読書感

プログラマが知るべき97のこと作者:出版社/メーカー: オライリージャパン発売日: 2010/12/18メディア: 単行本(ソフトカバー) 会社の先輩に、この本「プログラマが知るべき97のこと 」が勧められて、頑張って2回読み終わらせました。 とても叡智を感じてい…

【2019.4最新】UnityでOpenPoseが使えるまでのインストール(約2時間)

OpenPoseのインストールは数年前と比べると簡単になっており、 本章はUnityのプラグインも含めて、スクリーンショットを含めながら分かりやすく説明します。 github.com 基本的に、に載せているインストール方法を実践しながらやっていきます。 なぜブログに…

Unity Certified Program試験に合格しました!

こんにちは、キンキンです。(@HoloLabInc) 昨日、Unity Certified Programという試験に合格しました^^ ので、ブログで色々シェアしたいと思います。 (質問は秘密保守義務がつけられることで、準備の方向性や自分が苦労してたところだけ載せます) ↓コース…

アルゴリズムの練習について(Python)Lv.0

こんにちは〜キンキンです! 5月から、わけがあって私はPythonを学んでアルゴリズムの勉強を始めた。 ので!三ヶ月ほどの心得やオススメの本、サイトなども載せます。 初心者は頭から読んで、経験者は飛ばして好きなところを読むといいでしょう。 アルゴリズ…

【OpenPose】のインストール方法とコンパイル詳細(約4時間)

OpenPoseとは OpenPoseは、人の体(膝、肘、目など)を検知し、そして検知した結果を可視化にしたライブライです。そしてこの技術はCVPR2017で発表された、DeepLearningを使った、単眼カメラでのスケルトン検出アルゴリズムが、OpenPoseという名称でライブラ…