-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay65
155 lines (127 loc) · 3.79 KB
/
Day65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//A. Divisibility Problem
//https://codeforces.com/problemset/problem/1328/A
import java.util.Scanner;
public class Adivisibilitypblm {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
int remainder = a % b; // Calculate the remainder
int moves = remainder == 0 ? 0 : b - remainder;
System.out.println(moves);
}
}
}
//A. Pangram
//https://codeforces.com/problemset/problem/520/A
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Apanagram {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
String s = sc.nextLine();
sc.close();
boolean result = checkIfPangram(s);
System.out.println(result ? "YES" : "NO");
}
public static boolean checkIfPangram(String s) {
Set<Character> set = new HashSet<>();
s = s.toLowerCase();
for (char ch : s.toCharArray()) {
if (ch >= 'a' && ch <= 'z') {
set.add(ch);
}
}
return set.size() == 26;
}
}
//A. I Wanna Be the Guy
//https://codeforces.com/problemset/problem/469/A
import java.util.Scanner;
import java.util.HashSet;
public class IWantToBeTheGuy {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
HashSet<Integer> coveredLevels = new HashSet<>();
int p = sc.nextInt();
for (int i = 0; i < p; i++) {
coveredLevels.add(sc.nextInt());
}
int q = sc.nextInt();
for (int i = 0; i < q; i++) {
coveredLevels.add(sc.nextInt());
}
sc.close(); class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
for(int i = 0;i<matrix.length;i++){
int left = 0;
int right = matrix[0].length-1;
while(left<=right){
int mid = left +(right - left)/2;
if(matrix[i][mid]==target){
return true;
}
else if(matrix[i][mid]<target){
left = mid+1;
}
else{
right = mid-1;
}
}
}
return false;
}
}
//69. Sqrt(x)
//https://leetcode.com/problems/sqrtx/
class Solution {
public int mySqrt(int x) {
int start = 0;
int end = x;
if (x < 2) return x;
while(start<=end){
int mid = start+(end-start)/2;
long midsquared = (long) mid*mid;
if(midsquared == x)
{
return mid;
}
else if(midsquared<x){
start = mid+1;
}
else{
end = mid-1;
}
}
return end;
}
}
// 74. Search a 2D Matrix
//https://leetcode.com/problems/search-a-2d-matrix/description/
class Solution {
public boolean searchMatrix(int[][] matrix, int target) {
for(int i = 0;i<matrix.length;i++){
int left = 0;
int right = matrix[0].length-1;
while(left<=right){
int mid = left +(right - left)/2;
if(matrix[i][mid]==target){
return true;
}
else if(matrix[i][mid]<target){
left = mid+1;
}
else{
right = mid-1;
}
}
}
return false;
}
}