WHY DP???
the straight forward solution is better
cgxy1995
@cgxy1995
Posts made by cgxy1995

RE: Java solution, DP

Simplest HashSet solution beats 97.74%
class MagicDictionary { Set<String> set = new HashSet<>(); /** Initialize your data structure here. */ public MagicDictionary() { } /** Build a dictionary through a list of words */ public void buildDict(String[] dict) { for(String s: dict) set.add(s); } /** Returns if there is any word in the trie that equals to the given word after modifying exactly one character */ public boolean search(String word) { char[] chars = word.toCharArray(); for(int i=0;i<chars.length;i++){ char c = chars[i]; for(char j='a';j<='z';j++){ if(j != c){ chars[i] = j; if(set.contains(String.valueOf(chars))) return true; } } chars[i] = c; } return false; } }

RE: Managers with at Least 5 Direct Reports
A simpler solution:
select e1.Name
from Employee e1 join Employee e2
on e1.Id = e2.ManagerId
group by e1.Id
having count(e1.Id) >= 5; 
RE: Tree Node
'''select id,case
when p_id is null then 'Root'
when id in (select t.p_id from tree as t) then 'Inner'
else 'Leaf'
end as type
from tree
order by id;
'''
my CASE solution simpler than this solution 
RE: Super Short & Easy Java O(n) Solution
The theory of this solution is: the max steps is max(max(throughput of every washer), max(give out of every washer)

LOL what is the point of this question, there is only 1 fixed answer
[a,b,c,d,f,g], answer is always [a/(b/c/d/f/g)], no exception.
This question is dumb

simple, short java bucket sort solution. O(n) time and O(1) space
public String frequencySort(String s) { if(s.length()==0) return ""; int[] bucket = new int[256]; List<int[]> list = new ArrayList<>(); for(int i=0;i<s.length();i++) bucket[s.charAt(i)]++; for(int i=0;i<256;i++){ if(bucket[i] > 0) list.add(new int[]{i, bucket[i]}); } Collections.sort(list, new Comparator<int[]>(){ public int compare(int[] a1, int[] a2){ return a2[1]  a1[1]; } }); StringBuilder sb = new StringBuilder(); for(int[] c: list){ while(c[1] > 0) sb.append((char)c[0]); } return sb.toString(); }

Short O(n) time O(1) space treeset solution
public int thirdMax(int[] nums) { TreeSet<Integer> max3 = new TreeSet<>(); int idx = 0; while(max3.size() < 3 && idx < nums.length) max3.add(nums[idx++]); if(max3.size() < 3) return max3.last(); for(int i=3;i<nums.length;i++){ if(nums[i] > max3.first()){ max3.add(nums[i]); if(max3.size() > 3) max3.pollFirst(); } } return max3.first(); }

RE: Share my solution
This is the code you want to write in an interview... great job
The other short solutions are great. But you just dont know how to explain it, which would be useless. 
RE: what's the difference between this and #297 ?
@jdrogin
in both kinds of trees, you have to traverse every node once, therefore I dont think BST can do any better than a normal binary tree