Last active
December 16, 2025 11:22
-
-
Save KrishGarg/3c0cffa8d739b2932497b34e41da2c41 to your computer and use it in GitHub Desktop.
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
| // odd 1 | |
| class RectanglePoint { | |
| public int length, breadth; | |
| public Point pnt; | |
| static class Point { | |
| public int cX, cY; | |
| public Point(int centreX, int centreY) { | |
| cX = centreX; | |
| cY = centreY; | |
| } | |
| } | |
| public RectanglePoint(int length, int breadth, int centreX, int centreY) { | |
| this.length = length; | |
| this.breadth = breadth; | |
| this.pnt = new Point(centreX, centreY); | |
| } | |
| public int distOrigin() { | |
| return (int) Math.ceil(Math.hypot(pnt.cX, pnt.cY)); | |
| } | |
| } | |
| // odd 2 | |
| import java.util.*; | |
| class StringMaxCounter { | |
| public String str; | |
| public StringMaxCounter(String str) { | |
| this.str = str; | |
| } | |
| public char calculateMaxCount() { | |
| Map<Character, Integer> freq = new HashMap<>(); | |
| for (char c : str.toCharArray()) { | |
| if (freq.containsKey(c)) { | |
| freq.put(c, freq.get(c) + 1); | |
| } else { | |
| freq.put(c, 1); | |
| } | |
| } | |
| char maxChar = str.toCharArray()[0]; | |
| int maxCharCnt = 0; | |
| for (Map.Entry<Character, Integer> e : freq.entrySet()) { | |
| char key = e.getKey(); | |
| int val = e.getValue(); | |
| if (val > maxCharCnt) { | |
| maxCharCnt = val; | |
| maxChar = key; | |
| } | |
| } | |
| return maxChar; | |
| } | |
| } | |
| // odd 3 | |
| import java.util.*; | |
| class StringCharCounter { | |
| public String str; | |
| public StringCharCounter(String str) { | |
| this.str = str; | |
| } | |
| public Map<Character, Integer> calculateCount() { | |
| Map<Character, Integer> freq = new HashMap<>(); | |
| for (char c : str.toCharArray()) { | |
| if (freq.containsKey(c)) { | |
| freq.put(c, freq.get(c) + 1); | |
| } else { | |
| freq.put(c, 1); | |
| } | |
| } | |
| return freq; | |
| } | |
| } | |
| // odd 4 | |
| // ENTER YOUR CODE HERE | |
| import java.util.Comparator; | |
| class BAComparator implements Comparator<BankAccount>{ | |
| @Override | |
| public int compare(BankAccount account1, BankAccount account2) { | |
| Integer balance1 = account1.balance; | |
| Integer balance2 = account2.balance; | |
| return balance1.compareTo(balance2); | |
| } | |
| } | |
| // DO NOT MODIFY THIS CLASS | |
| class BankAccount { | |
| public Integer balance; | |
| public BankAccount(int balance) { | |
| this.balance = balance; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment