diff --git a/code/src/com/allendowney/thinkdast/N3Array.java b/code/src/com/allendowney/thinkdast/N3Array.java new file mode 100644 index 00000000..593c4537 --- /dev/null +++ b/code/src/com/allendowney/thinkdast/N3Array.java @@ -0,0 +1,41 @@ +import java.util.*; +import java.util.Map.Entry; +public class N3Array { + public static void n3array(int arr[]) + { + int n=arr.length; + Maphm=new HashMap<>(); + int count=0; + for(int i=0;i=1) + { + count=hm.get(arr[i]); + hm.put(arr[i],count+1); + } + } + } + Iterator>it=hm.entrySet().iterator(); + while(it.hasNext()) + { + Entry entry=it.next(); + if(entry.getValue()>(n/3)) + { + System.out.println(entry.getKey()); + } + + } + + } +public static void main(String []args) +{ + int arr[]= {3, 3, 4, 2, 4, 4, 2, 4, 4}; + n3array(arr); +} +} diff --git a/code/src/com/allendowney/thinkdast/NextPermutation.java b/code/src/com/allendowney/thinkdast/NextPermutation.java new file mode 100644 index 00000000..5ec6ad92 --- /dev/null +++ b/code/src/com/allendowney/thinkdast/NextPermutation.java @@ -0,0 +1,34 @@ +import java.util.*; +public class NextPermutation { + public static void permute(int a[]) + { + int n=a.length; + for(int i=n-1;i>0;i-- ) + { + if(a[i]>a[i-1]) + { + int num=a[i-1]; + for(int j=i-1;jv) + { + int min=v.get(0); + int n=v.size(); + for(int i=0;iv.get(i)) + { + min=v.get(i); + + } + } + if(min==n-1) + { + System.out.println("Nobel Integer :"+ min); + } + else + { + System.out.println("Nobel Integer: "+0); + } + } +public static void main(String []args) +{ + Vector vec=new Vector<>(); + vec.add(15); + vec.add(17); + vec.add(18); + vec.add(14); + vec.add(4); + findnobelInt(vec); + +} +} diff --git a/code/src/com/allendowney/thinkdast/Parenthisischecker.java b/code/src/com/allendowney/thinkdast/Parenthisischecker.java new file mode 100644 index 00000000..aacfc957 --- /dev/null +++ b/code/src/com/allendowney/thinkdast/Parenthisischecker.java @@ -0,0 +1,46 @@ +import java.util.*; +public class Parenthisischecker { + static void checkparent(String str) + { + + Stacks=new Stack<>(); + + + + for(int i1=0;i1