DEV Community

loading...
Vidit Sarkar profile picture

Vidit Sarkar

Studying Computer Science & Engineering. Prefer to write clean and easy-to-understand code. Languages I use Python, C++, C, Java Script and Java.

Location India Joined Joined on  github website

Education

Bachelor of Computer Science & Engineering

All 88 comments

A Google Interview Question

I think the expected answer of first additional example shoul...

Leetcode Daily - Longest Palindrome

Thanks for sharing the problem and your solution. Here is my ...

Python | Isogram Problem!

Yes, you are right!

Python | Isogram Problem!

Let's take the example , s = "Six-Year- Old". replace('-', ''...

Python | Isogram Problem!

def is_isogram(str): cleaned = str.replace('-', '').repla...

Unconditional Challenge: FizzBuzz without `if`

Thanks for the reply. I think re-submission is also allowed. ...

Daily Challenge #260 - Subtract the Sum

And here is a recursive Python solution, fruits = [ "ki...

Daily Challenge #260 - Subtract the Sum

Here is a solution, return "apple";

Daily Challenge #259 - Duplicate Encoder

Here is a C++ solution, string encodeDuplicate(string s){ ...

Unconditional Challenge: FizzBuzz without `if`

Thanks for the problem. I guess this will not satisfy your co...

Daily Challenge #257 - Halving Sum

Here is a Python solution, halvingSum = lambda n : n and (...

Daily Challenge #256 - How Many Are Smaller Than I?

Here is a C++ solution, vector<int> smaller(vector&lt...

Daily Challenge #255 - Is There an Odd Bit?

Here is a C++ solution, (considering given number is positive...

Daily Challenge #253 - Sort Sentences Pseudo-alphabetically

Here is a Python solution, from string import punctuation ...

6-10PM challenge problem #006

Here is a Python solution, def shiftArr(arr , num): low...

6-10PM challenge problem #005

Here is a Python solution, def flat_dict(d : dict) -> d...

Invert a Binary tree Leetcode solution

Thanks for the problem and solution. Here is my solution, v...

Daily Challenge #250 - Last Digit of a Large Number

vector<vector<int>> can also be used. But I think...

Daily Challenge #251 - Largest Number in a Sequence

Here is a Python solution, def digit5(number : str) -> i...

Daily Challenge #250 - Last Digit of a Large Number

Here is a C++ solution, #include <bits/stdc++.h> usin...

Daily Challenge #244 - Search for Letters

Here is a C++ solution, string change(string s){ string...

Daily Challenge #243 - Redacted!

Here is a C++ solution, bool areSame(string doc1, string do...

Daily Challenge #242 - Expressions Matter

Here is a Python solution, expression_formats = [ '{}+{...

Daily Challenge #240 - ATM

Here is a C++ solution, int solve(int n){ if(n < 10 ...

Daily Challenge #238 - One is the Loneliest Number

Here is a Python solution, def lonelyNum(number : int) -&g...

Daily Challenge #237 - Delete Extra Occurrences

ans vector contains each number only up to occ times. So, occ...

Daily Challenge #237 - Delete Extra Occurrences

Here is C++ solution, vector<int> delete_nth(vector&l...

Daily Challenge #236 - RGB to Hex Conversion

Here is a short Python solution, def rgb(r, g, b): retu...

Daily Challenge #234 - Happy Birthday!

This function checks if given age can be translated to the gi...

Daily Challenge #231 - Perfect Powers

Python solution, import math def isPP(number : int) -> ...

Daily Challenge #230 - Beeramid

Here is a Python Solution, def beeramid(bonus, price): ...

Daily Challenge #228 - Best Profit in Single Sale

Here I represented the loss with negative number. For the l...

Daily Challenge #228 - Best Profit in Single Sale

Here is a short Python recursive solution, def max_profit...

Daily Challenge #228 - Best Profit in Single Sale

C++ solution #include <iostream> #include <vecto...

Daily Challenge #225 - Square'n'Sum

I am in love with Python. square_sum = lambda lst: sum(ma...

Daily Challenge #224 - Password Validator

Python solution passwordValidator = lambda password : "VA...

Daily Challenge #223 - Responsible Drinking

Thanks!

Daily Challenge #223 - Responsible Drinking

I want to suggest a challenge. What should be the subject o...

Daily Challenge #223 - Responsible Drinking

Python solution import re def hydrate(drinks: str) ->...

Daily Challenge #222 - Parse Bank Account Numbers

Python solution # stores the modified string representati...

Daily Challenge #221 - The Merchant of York

Hope I have got the problem right. Here is a possible Pytho...

Daily Challenge #220 - What Dominates Your Array?

C++ solution int dominator(vector<int> arr){ //...

Daily Challenge #219 - Compare Strings

Python one liner, strCount = lambda str1, str2: len(str1)...

Daily Challenge #218 - Possible Sides of a Non-Right Triangle

Here is a Python one liner, side_len = lambda a, b: [c fo...

Daily Challenge #218 - Possible Sides of a Non-Right Triangle

C++ solution // check if three integers a, b, c can form ...

Daily Challenge #217 - SMS w/ an Old Phone

Here is Python solution based on my C++ solution # return...

Daily Challenge #217 - SMS w/ an Old Phone

C++ solution #include <iostream> #include <vecto...

Daily Challenge #216 - Rainfall

Python solution # load the data in a dictionary # dict ke...

Daily Challenge #215 - Difference of 2

Thanks!

Daily Challenge #215 - Difference of 2

Python solution pairDifference = lambda lst: sorted([(num...

Daily Challenge #215 - Difference of 2

C++ solution vector<pair<int, int>> pairDiffer...

Daily Challenge #214 - Persistent Bugger

Python solution from functools import reduce persistence ...

Daily Challenge #214 - Persistent Bugger

C++ solution /* Recursion : persistence(num) = 0 if num &...

Daily Challenge #213 - Are they the "same"?

Python solution from collections import Counter comp = la...

Daily Challenge #213 - Are they the "same"?

C++ solution bool comp(vector<int> a, vector<int...

Daily Challenge #212 - DNA to RNA

Python solution DNAtoRNA = lambda dna : dna.replace('T','...

Daily Challenge #212 - DNA to RNA

C++ solution string DNAtoRNA(string dna){ replace(dna...

Daily Challenge #207 - Snakes and Ladders

It was fun #include <bits/stdc++.h> using namespace s...

Daily Challenge #206 - Pound Means Backspace

Here is a ugly Python one-liner using lambda. Use Python 3....

Daily Challenge #206 - Pound Means Backspace

Hope this is right, C++ string cleanString(string s){ ...

Daily Challenge #205 - Consonant String Value

Here is a Python one-liner import re solve = lambda s : m...

Daily Challenge #205 - Consonant String Value

C++ solution using simple for-loop int solve(string s){ ...

Daily Challenge #204 - Partial Keys

Python approach class ObjectSpecial: def __init__(sel...

Daily Challenge #204 - Partial Keys

Hope I have got the problem right. Here is the C++ solution...

Daily Challenge #203 - Pascal's Triangle

Python one-liner using recursion easyLine = lambda n : 1 ...

Daily Challenge #203 - Pascal's Triangle

C++ // calculate nCr in O(r) time long long binCoef(int n...

Daily Challenge #202 - Complete the Pattern II

Here is a recursive approach using Python def pattern(num...

Daily Challenge #202 - Complete the Pattern II

Python one-liner pattern = lambda number : '\n'.join([''....

Daily Challenge #202 - Complete the Pattern II

No new-line at the end. C++ string pattern(int n){ st...

Daily Challenge #201 - Complete the Pattern

Python one liner : pattern = lambda number : '\n'.join([s...

Daily Challenge #201 - Complete the Pattern

I think there is no new-line at the end. Here is C++ soluti...

Daily Challenge #199 - List of All Rationals

C++ // returns the pos-th element in the allRationals lis...

Daily Challenge #198 - 21 Blackjack

Test cases -- cout << scoreHand({"A"}) << "\n...

Daily Challenge #198 - 21 Blackjack

C++ int scoreHand(vector<string> cards){ unorde...

Daily Challenge #197 - Population Growth

Starting population : p0 Percent : pct Inhabitants coming o...

Daily Challenge #195 - No Zeroes for Heroes

I guess you just need to add a 'return' in front of remov...

Daily Challenge #195 - No Zeroes for Heroes

Python one liner eradicate = lambda number : 0 if number=...

Daily Challenge #195 - No Zeroes for Heroes

C++ int removeZeros(int number){ // if number is 0 re...

Daily Challenge #194 - Spread Number

C++ vector<int> spreadNumber(int number){ vecto...

Daily Challenge #193 - What's the Real Floor?

C++ one liner int getRealFloor(int americanFloor){ //...

Daily Challenge #192 - Can you Survive the Zombies?

C++ // takes number of bullets and percentage of missing ...

Daily Challenge #191 - Alphabetical Addition

C++ // takes letters in a vector char addLetters(vector&l...

Daily Challenge #190 - capitalizeFirstLast

C++ string capitalizeFirstLast(string s){ string modi...

Daily Challenge #189 - Convert Number into Reversed Array

C++ vector<int> convertNtA(long number){ vector...

Daily Challenge #188 - Break camelCase

C++ solution string ccbreaker(string camelCased){ str...

Daily Challenge #187 - Most Sales

Here is C++ solution vector<string> highestRevenue(...

Daily Challenge #185 - House Numbers Sum

C++ solution int sumHouse(vector<int> numbers){ ...

Daily Challenge #184 - Form the Minimum

Here is my C++ code vector<int> minValueHelper(vect...

loading...