Google Interview
問題 leetcode.com s = "3[a]2[bc]", return "aaabcbc". s = "3[a2[c]]", return "accaccacc". s = "2[abc]3[cd]ef", return "abcabccdcdcdef". このように[]で囲まれた文字を直前の数字の数だけ繰り返しながら文字列を作って行く問題。 解法 これはStackを…
Problem https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/ How to Solve This problem is classified into Tree and can be solve by using DFS(Depth First Search). Depth First Search Firstly, I thought the only search by D…
Problem https://leetcode.com/problems/zigzag-iterator/ How to Solve By using Iterator and Queue, I can solve this problem. Iterator ListIterator (Java Platform SE 8 ) An iterator for lists that allows the programmer to traverse the list in…
Problem https://leetcode.com/problems/bomb-enemy/ How to Solve This problem can be solved by using Dynamic Programming. The point of this problem is that one spot in the grid can divide into four direction (up, down, left, right). We can c…
Problem https://leetcode.com/problems/range-sum-query-2d-mutable/ How to Solve This problem can be solved by using Binary Indexed Tree. Please check below article if you want to know the details of Binary Indexed Tree. keita-matsushita.hat…
Problem leetcode.com How to Solve This problem is solved by the following steps. find out index that each letter appears int the last position have the indexes calculating at step 1 in a array sort the arrays created at step2 4 check the s…
Problem https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/ Given a string, find the length of the longest substring T that contains at most k distinct characters. For example, Given s = "eceba" and k = 2, T…
Problem leetcode.com We are given a string as a file path like this: "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext". This string means directory structure below. We answer a number of max length of file path like this: 20 (number of length abou…