Skip to content

Instantly share code, notes, and snippets.

View codeperfectplus's full-sized avatar
🟢
Online

Deepak Raj codeperfectplus

🟢
Online
View GitHub Profile
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int solveMeFirst(int a, int b) {
// Hint: Type return a+b; below:
return a + b;
def solveMeFirst(a:int,b:int):
# Hint: Type return a+b below
return a + b
num1 = int(input())
num2 = int(input())
res = solveMeFirst(num1,num2)
print(res)
# Enter your code here. Read input from STDIN. Print output to STDOUT
import itertools
def compress_the_string(string):
res = itertools.groupby(string)
for k, g in res:
print((len(list(g)), int(k)), end=' ')
if __name__ == '__main__':
string = input()
class Solution {
public:
int reverse(int x) {
int rev = 0;
while (x != 0) {
int pop = x % 10;
x /= 10;
if (rev > INT_MAX / 10 || rev < INT_MIN / 10) return 0;
rev = rev * 10 + pop;
}
class Solution {
public int reverse(int x) {
StringBuilder s = new StringBuilder();
s.append(Math.abs(x));
s.reverse();
if (s.length() >= 10 ){
int c1 = Integer.parseInt(s.substring(0 , 5) );
int c2 = Integer.parseInt(s.substring(5 , 10) );
if (c1 > 21474 || c2 > 83647){
return 0;
class Solution:
def reverse(self, x: int) -> int:
a = 0
if x >= 0:
a = int(str(x)[::-1])
elif x < 0:
a = -1 * int(str(abs(x))[::-1])
if a >= 2**31-1 or a <= -2**31:
# The Minion Game - HackerRank Solution Python
def minion_game(string):
# your code goes here
vowels = 'AEIOU'
stuart_score = 0
kevin_score = 0
for i in range(len(string)):
if string[i] in vowels:
import itertools
def find_probability(arr, k):
# generate all possible combinations
all_combinations = list(itertools.combinations(arr, k))
# find total number of combinations
total_combinations = len(all_combinations)
# find number of combinations that satisfy the condition
satisfied_combinations = len([x for x in all_combinations if 'a' in x])
# find probability
import re
def substitute_text_in_string(text: str):
"""
Substitute text in string
&& -> and
|| -> or
change only if there are spaces around
"""
def test_case():
arr = [1, 5, 3]
A = {1, 3}
B = {5, 7}
no_idea(arr, A, B)
test_case()