Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
DSA and SQL Practice Set
00:00
5 left

DSA and SQL Practice Set

EasyPython

Problem

Q1. CoderPad-friendly DSA problem on Sum of Digits with multiple variations and solutions for example do the sum until you get a single digit number for any given number Q2. SQL Join like -- List the Second Highest Salary By Department Listing the second-highest salary by the department is a practical example that showcases the use of advanced SQL techniques. PostgreSQL is a powerful open-source relational database that offers below functions to List the Second Highest Salary By Department are as follows:

Implement Q1 as a Python function. Given an integer, repeatedly sum its decimal digits until the result is a single digit.

Input and Output

def sum_digits_until_single(number): accepts an integer and returns an integer from 0 through 9. Negative inputs are processed using their absolute value.

Constraints

  • -10^18 <= number <= 10^18
  • The input is an integer.
  • Return the final single digit as an integer from 0 through 9.

Function Signature

def sum_digits_until_single(number):
Interviewer

Your question is DSA and SQL Practice Set. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.