資源簡介
《程序員代碼面試指南》-左程云(高清PDF+源代碼)
代碼片段和文件信息
package?chapter_1_stackandqueue;
import?java.util.Stack;
public?class?Problem_01_GetMinStack?{
public?static?class?MyStack1?{
private?Stack?stackData;
private?Stack?stackMin;
public?MyStack1()?{
this.stackData?=?new?Stack();
this.stackMin?=?new?Stack();
}
public?void?push(int?newNum)?{
if?(this.stackMin.isEmpty())?{
this.stackMin.push(newNum);
}?else?if?(newNum?<=?this.getmin())?{
this.stackMin.push(newNum);
}
this.stackData.push(newNum);
}
public?int?pop()?{
if?(this.stackData.isEmpty())?{
throw?new?RuntimeException(“Your?stack?is?empty.“);
}
int?value?=?this.stackData.pop();
if?(value?==?this.getmin())?{
this.stackMin.pop();
}
return?value;
}
public?int?getmin()?{
if?(this.stackMin.isEmpty())?{
throw?new?RuntimeException(“Your?stack?is?empty.“);
}
return?this.stackMin.peek();
}
}
public?static?class?MyStack2?{
private?Stack?stackData;
private?Stack?stackMin;
public?MyStack2()?{
this.stackData?=?new?Stack();
this.stackMin?=?new?Stack();
}
public?void?push(int?newNum)?{
if?(this.stackMin.isEmpty())?{
this.stackMin.push(newNum);
}?else?if?(newNum? this.stackMin.push(newNum);
}?else?{
int?newMin?=?this.stackMin.peek();
this.stackMin.push(newMin);
}
this.stackData.push(newNum);
}
public?int?pop()?{
if?(this.stackData.isEmpty())?{
throw?new?RuntimeException(“Your?stack?is?empty.“);
}
this.stackMin.pop();
return?this.stackData.pop();
}
public?int?getmin()?{
if?(this.stackMin.isEmpty())?{
throw?new?RuntimeException(“Your?stack?is?empty.“);
}
return?this.stackMin.peek();
}
}
public?static?void?main(String[]?args)?{
MyStack1?stack1?=?new?MyStack1();
stack1.push(3);
System.out.println(stack1.getmin());
stack1.push(4);
System.out.println(stack1.getmin());
stack1.push(1);
System.out.println(stack1.getmin());
System.out.println(stack1.pop());
System.out.println(stack1.getmin());
System.out.println(“=============“);
MyStack1?stack2?=?new?MyStack1();
stack2.push(3);
System.out.println(stack2.getmin());
stack2.push(4);
System.out.println(stack2.getmin());
stack2.push(1);
System.out.println(stack2.getmin());
System.out.println(stack2.pop());
System.out.println(stack2.getmin());
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???84913678??2016-08-21?10:25??《程序員代碼面試指南》-左程云\程序員代碼面試指南?IT名企算法與數據結構題目最優解?左程云著?.pdf
?????文件????????226??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\.classpath
?????文件????????378??2015-03-13?17:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\.project
?????文件????????587??2015-03-13?17:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\.settings\org.eclipse.jdt.core.prefs
?????文件???????1461??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_01_GetMinStack$MyStack1.class
?????文件???????1482??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_01_GetMinStack$MyStack2.class
?????文件???????1198??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_01_GetMinStack.class
?????文件???????1532??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_02_TwoStacksImplementQueue$TwoStacksQueue.class
?????文件???????1013??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_02_TwoStacksImplementQueue.class
?????文件???????1698??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_03_ReverseStackUsingRecursive.class
?????文件????????523??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_04_DogCatQueue$Cat.class
?????文件????????523??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_04_DogCatQueue$Dog.class
?????文件???????2870??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_04_DogCatQueue$DogCatQueue.class
?????文件????????626??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_04_DogCatQueue$Pet.class
?????文件???????1079??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_04_DogCatQueue$PetEnterQueue.class
?????文件???????1975??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_04_DogCatQueue.class
?????文件???????1582??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_05_StackSortStack.class
?????文件???????1393??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_06_HanoiStack$Action.class
?????文件???????4465??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_06_HanoiStack.class
?????文件???????1963??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_07_SlidingWindowMaxArray.class
?????文件????????521??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_08_MaxTree$Node.class
?????文件???????3731??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_08_MaxTree.class
?????文件???????1992??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_09_MaximalRectangle.class
?????文件???????2383??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_1_stackandqueue\Problem_10_AllLessNumSubArray.class
?????文件????????531??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_2_listproblem\Problem_01_PrintCommonPart$Node.class
?????文件???????1961??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_2_listproblem\Problem_01_PrintCommonPart.class
?????文件????????572??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_2_listproblem\Problem_02_RemoveLastKthNode$DoubleNode.class
?????文件????????539??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_2_listproblem\Problem_02_RemoveLastKthNode$Node.class
?????文件???????3184??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_2_listproblem\Problem_02_RemoveLastKthNode.class
?????文件????????539??2016-03-26?11:52??《程序員代碼面試指南》-左程云\程序員代碼面試指南-代碼\BookCode\bin\chapter_2_listproblem\Problem_03_RemoveNodeByRatio$Node.class
............此處省略414個文件信息
評論
共有 條評論