摘要:
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Cou... 阅读全文
摘要:
my solution: put integer A[i] at index A[i]-1 unless A[i] already equals i +1 or A[i] == A[A[i]-1] later scan again if at index i, A[i] != i+1, then A 阅读全文
摘要:
the same with word ladder 写的时候语法上出了一些问题 第5行不用给char数组赋大小 第20行用stringbuilder的时候曾经写成:String afterMutation = new StringBuilder(cur).setCharAt(i, c).toStri 阅读全文
摘要:
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely... 阅读全文
摘要:
refer to https://discuss.leetcode.com/topic/68896/java-solution-using-hashmap-with-detailed-explanation After solving several "Game Playing" questions 阅读全文
摘要:
这道题应该没法用DP等解,只能brute force 或者 KMP(为深究) BruteForce, Best Solution for now except KMP 作为Encode String with Shortest Length的subproblem KMP解法未研究,https://d 阅读全文
摘要:
Solution 1: Greedy, Time:O(nlogn) Just assign the cookies starting from the child with less greediness to maximize the number of happy children . Solu 阅读全文