From e503ed72398ad238072c60171bfcdcba7a9a6362 Mon Sep 17 00:00:00 2001 From: samarthteck <72140408+samarthteck@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:12:25 +0530 Subject: [PATCH] Add files via upload I have add some stuff plz check and accept it --- .../com/allendowney/thinkdast/N3Array.java | 41 +++++++++++++++++ .../thinkdast/NextPermutation.java | 34 ++++++++++++++ .../com/allendowney/thinkdast/NobelInt.java | 39 ++++++++++++++++ .../thinkdast/Parenthisischecker.java | 46 +++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 code/src/com/allendowney/thinkdast/N3Array.java create mode 100644 code/src/com/allendowney/thinkdast/NextPermutation.java create mode 100644 code/src/com/allendowney/thinkdast/NobelInt.java create mode 100644 code/src/com/allendowney/thinkdast/Parenthisischecker.java 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