Coding problems ( HackWithInfy)
Coding problems ( HackWithInfy)
Ramu has N dishes of different types arranged in a row: A1,A2,…,AN where Ai denotes the type of
the ith dish. He wants to choose as many dishes as possible from the given list but while satisfying
two conditions:
Ramu wants to know which type of dish he should choose from, so that he can pick the maximum
number of dishes.
Example :
For type 1, Ramu can choose at most four dishes. One of the ways to choose four dishes of type 1 is
A1,A4, A7 and A9.
For type 2, Ramu can choose at most two dishes. One way is to choose A3 and A5.
So in this case, Ramu should go for type 1, in which he can pick more dishes.
INPUT FORMAT:
The first line contains T, the number of test cases. Then the test cases follow.
For each test case, the first line contains a single integer N.
OUTPUT FORMAT
For each test case, print a single line containing one integer ― the type of the dish that Ramu should
choose from. If there are multiple answers, print the smallest one.
CONSTRAINTS :
Sample Input :
12212
111111
12223421
Sample Output :
You are given an array of variable pairs equations and an array of real numbers values,
where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is a
string that represents a single variable.
You are also given some queries, where queries[j] = [Cj, Dj] represents the jth query where you must
find the answer for Cj / Dj = ?.
Return the answers to all queries. If a single answer cannot be determined, return -1.0.
Note: The input is always valid. You may assume that evaluating the queries will not result in division
by zero and that there is no contradiction.
Note: The variables that do not occur in the list of equations are undefined, so the answer cannot be
determined for them.
Example 1:
Output: [6.00000,0.50000,-1.00000,1.00000,-1.00000]
Explanation:
queries are: a / c = ?, b / a = ?, a / e = ?, a / a = ?, x / x = ?
Example 2:
Output: [3.75000,0.40000,5.00000,0.20000]
Example 3:
Constraints:
equations[i].length == 2
values.length == equations.length
queries[i].length == 2
Ai, Bi, Cj, Dj consist of lower case English letters and digits.
import java.util.*;
/*
12212
111111
12223421
*/
class Main {
int i = 0;
int maximum = 0;
int type = a[0];
int c = 0;
while(i <= n - 1) { // i = 0
int j = i + 1; // j = 1
int counter = 1;
while(j < n) { // 1, 2 , 3, 4
counter = counter+ 1;
c = counter;
j = j+ 1;
j = j + 1;
maximum = c;
type = a[i];
i = i + 1;
}
public static void main(String args[]) {
int n = s.nextInt();
a[k] = s.nextInt();
solution(a , n);
https://leetcode.com/discuss/post/1326900/graph-algorithms-problems-to-practice-by-9u6j/
https://leetcode.com/problems/evaluate-division/description/