摘要:
Given an array of integers, find out whether there are two distinct indicesiandjin the array such that the difference betweennums[i]andnums[j]is at mo... 阅读全文
摘要:
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文
摘要:
还有2个queue做,没写class MyStack { public Queue q = new LinkedList(); //cc150的问题,好像 // single queue public void push(int x) { q.add((int)... 阅读全文
摘要:
Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文
摘要:
排排坐分果果,这道题还是蛮难想的,答案忘了从哪里看的了 public int candy(int[] ratings) { if(ratings == null) return 0; int len = ratings.length; int res ... 阅读全文
摘要:
我觉得这道题是dp比较有趣的应用吧,但是老用不熟sigh一下public class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { int total=0, curRem=0, curSum=0... 阅读全文
摘要:
典型的dfs,做个hashmap判断是否存过(oldnode,newnode)最后怎么把neighbor加入到hm对应node的neighbor list中比较关键public class Solution { public UndirectedGraphNode cloneGraph(Und... 阅读全文
摘要:
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs... 阅读全文
摘要:
正常dfspublic class Solution { public ArrayList> partition(String s) { ArrayList> res = new ArrayList>(); if(s==null||s.length()==0) re... 阅读全文
摘要:
Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region... 阅读全文