File tree Expand file tree Collapse file tree 5 files changed +173
-0
lines changed
solution/1800-1899/1832.Check if the Sentence Is Pangram Expand file tree Collapse file tree 5 files changed +173
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,81 @@ func checkIfPangram(sentence string) bool {
162
162
}
163
163
```
164
164
165
+ ### ** TypeScript**
166
+
167
+ ``` ts
168
+ function checkIfPangram(sentence : string ): boolean {
169
+ const vis = new Array (26 ).fill (false );
170
+ for (const c of sentence ) {
171
+ vis [c .charCodeAt (0 ) - ' a' .charCodeAt (0 )] = true ;
172
+ }
173
+ return vis .every (v => v );
174
+ }
175
+ ```
176
+
177
+ ``` ts
178
+ function checkIfPangram(sentence : string ): boolean {
179
+ let mark = 0 ;
180
+ for (const c of sentence ) {
181
+ mark |= 1 << (c .charCodeAt (0 ) - ' a' .charCodeAt (0 ));
182
+ }
183
+ return mark === (1 << 26 ) - 1 ;
184
+ }
185
+ ```
186
+
187
+ ### ** Rust**
188
+
189
+ ``` rust
190
+ impl Solution {
191
+ pub fn check_if_pangram (sentence : String ) -> bool {
192
+ let mut vis = [false ; 26 ];
193
+ for c in sentence . as_bytes () {
194
+ vis [(* c - b 'a' ) as usize ] = true ;
195
+ }
196
+ vis . iter (). all (| v | * v )
197
+ }
198
+ }
199
+ ```
200
+
201
+ ``` rust
202
+ impl Solution {
203
+ pub fn check_if_pangram (sentence : String ) -> bool {
204
+ let mut mark = 0 ;
205
+ for c in sentence . as_bytes () {
206
+ mark |= 1 << * c - b 'a' ;
207
+ }
208
+ mark == (1 << 26 ) - 1
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### ** C**
214
+
215
+ ``` c
216
+ bool checkIfPangram (char * sentence) {
217
+ int vis[ 26] = {0};
218
+ for (int i = 0; sentence[ i] ; i++) {
219
+ vis[ sentence[ i] - 'a'] = 1;
220
+ }
221
+ for (int i = 0; i < 26; i++) {
222
+ if (!vis[ i] ) {
223
+ return 0;
224
+ }
225
+ }
226
+ return 1;
227
+ }
228
+ ```
229
+
230
+ ```c
231
+ bool checkIfPangram(char *sentence) {
232
+ int mark = 0;
233
+ for (int i = 0; sentence[i]; i++) {
234
+ mark |= 1 << (sentence[i] - 'a');
235
+ }
236
+ return mark == (1 << 26) - 1;
237
+ }
238
+ ```
239
+
165
240
### ** ...**
166
241
167
242
```
Original file line number Diff line number Diff line change @@ -136,6 +136,81 @@ func checkIfPangram(sentence string) bool {
136
136
}
137
137
```
138
138
139
+ ### ** TypeScript**
140
+
141
+ ``` ts
142
+ function checkIfPangram(sentence : string ): boolean {
143
+ const vis = new Array (26 ).fill (false );
144
+ for (const c of sentence ) {
145
+ vis [c .charCodeAt (0 ) - ' a' .charCodeAt (0 )] = true ;
146
+ }
147
+ return vis .every (v => v );
148
+ }
149
+ ```
150
+
151
+ ``` ts
152
+ function checkIfPangram(sentence : string ): boolean {
153
+ let mark = 0 ;
154
+ for (const c of sentence ) {
155
+ mark |= 1 << (c .charCodeAt (0 ) - ' a' .charCodeAt (0 ));
156
+ }
157
+ return mark === (1 << 26 ) - 1 ;
158
+ }
159
+ ```
160
+
161
+ ### ** Rust**
162
+
163
+ ``` rust
164
+ impl Solution {
165
+ pub fn check_if_pangram (sentence : String ) -> bool {
166
+ let mut vis = [false ; 26 ];
167
+ for c in sentence . as_bytes () {
168
+ vis [(* c - b 'a' ) as usize ] = true ;
169
+ }
170
+ vis . iter (). all (| v | * v )
171
+ }
172
+ }
173
+ ```
174
+
175
+ ``` rust
176
+ impl Solution {
177
+ pub fn check_if_pangram (sentence : String ) -> bool {
178
+ let mut mark = 0 ;
179
+ for c in sentence . as_bytes () {
180
+ mark |= 1 << * c - b 'a' ;
181
+ }
182
+ mark == (1 << 26 ) - 1
183
+ }
184
+ }
185
+ ```
186
+
187
+ ### ** C**
188
+
189
+ ``` c
190
+ bool checkIfPangram (char * sentence) {
191
+ int vis[ 26] = {0};
192
+ for (int i = 0; sentence[ i] ; i++) {
193
+ vis[ sentence[ i] - 'a'] = 1;
194
+ }
195
+ for (int i = 0; i < 26; i++) {
196
+ if (!vis[ i] ) {
197
+ return 0;
198
+ }
199
+ }
200
+ return 1;
201
+ }
202
+ ```
203
+
204
+ ```c
205
+ bool checkIfPangram(char *sentence) {
206
+ int mark = 0;
207
+ for (int i = 0; sentence[i]; i++) {
208
+ mark |= 1 << (sentence[i] - 'a');
209
+ }
210
+ return mark == (1 << 26) - 1;
211
+ }
212
+ ```
213
+
139
214
### ** ...**
140
215
141
216
```
Original file line number Diff line number Diff line change
1
+ bool checkIfPangram (char * sentence ) {
2
+ int mark = 0 ;
3
+ for (int i = 0 ; sentence [i ]; i ++ ) {
4
+ mark |= 1 << (sentence [i ] - 'a' );
5
+ }
6
+ return mark == (1 << 26 ) - 1 ;
7
+ }
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn check_if_pangram ( sentence : String ) -> bool {
3
+ let mut mark = 0 ;
4
+ for c in sentence. as_bytes ( ) {
5
+ mark |= 1 << * c - b'a' ;
6
+ }
7
+ mark == ( 1 << 26 ) - 1
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ function checkIfPangram ( sentence : string ) : boolean {
2
+ let mark = 0 ;
3
+ for ( const c of sentence ) {
4
+ mark |= 1 << ( c . charCodeAt ( 0 ) - 'a' . charCodeAt ( 0 ) ) ;
5
+ }
6
+ return mark === ( 1 << 26 ) - 1 ;
7
+ }
You can’t perform that action at this time.
0 commit comments