This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.BufferedReader; | |
| import java.io.InputStreamReader; | |
| import java.io.*; | |
| public class knapsack { | |
| public static void main(String[] args){ | |
| BufferedReader reader=new BufferedReader(new InputStreamReader(System.in)); | |
| int realtarget=0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List list = new ArrayList(wordCountMap.entrySet()); | |
| Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() { | |
| @Override | |
| public int compare(Map.Entry<Integer, Integer> a, Map.Entry<Integer, Integer> b) { | |
| return a.getValue() - b.getValue(); | |
| } | |
| }); | |
| Collections.reverse(list); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long start = System.currentTimeMillis(); | |
| //write your code here | |
| long timeSpent = System.currentTimeMillis() - start; | |
| System.out.println(timeSpent + " ms"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<Person> persons = personsExtracter.getPersons(); | |
| Collections.sort(persons, new AgeComparator()); | |
| public class AgeComparator implements Comparator<Person> { | |
| @Override | |
| public int compare(Person o1, Person o2) { | |
| Integer age1 = o1.getAge(); | |
| Integer age2 = o2.getAge(); | |
| return age1.compareTo(age2); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void write() throws FileNotFoundException, UnsupportedEncodingException { | |
| PrintWriter printWriter = new PrintWriter(new OutputStreamWriter( | |
| new FileOutputStream(file, true), "UTF-8")); | |
| Scanner scanner = new Scanner(System.in); | |
| String line; | |
| while (true) { | |
| line = scanner.nextLine(); | |
| if ("--stop".equals(line)) break; | |
| printWriter.println(line); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.io.*; | |
| class | |
| { | |
| /************************ SOLUTION STARTS HERE ************************/ | |
| private static void solve(FastScanner s1, PrintWriter out){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package preparingDB; | |
| import java.io.BufferedReader; | |
| import java.io.FileReader; | |
| import java.io.IOException; | |
| import java.io.PrintWriter; | |
| import java.util.*; | |
| import java.util.concurrent.LinkedBlockingQueue; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| Integer number = 255; | |
| // Бинарный формат числа | |
| String convert = Integer.toBinaryString(number); | |
| System.out.println(convert); | |
| // Восьмиричная форма | |
| convert = Integer.toOctalString(number); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Sort | |
| { | |
| public static Map<Double, String> map = new TreeMap<Double, String>(Collections.reverseOrder()); | |
| public static void main(String args[]) | |
| { | |
| // create linked list object | |
| LinkedList<Integer> list = new LinkedList<Integer>(); | |
| // populate the list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.hadoop.conf.Configured; | |
| import org.apache.hadoop.fs.Path; | |
| import org.apache.hadoop.io.IntWritable; | |
| import org.apache.hadoop.io.LongWritable; | |
| import org.apache.hadoop.io.Text; | |
| import org.apache.hadoop.mapreduce.Job; | |
| import org.apache.hadoop.mapreduce.Mapper; | |
| import org.apache.hadoop.mapreduce.Reducer; | |
| import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; | |
| import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; |
NewerOlder