Skip to main content

6 posts tagged with "algo"

View All Tags

· 4 min read

description

Given an array of positive integers representing the values of coins in your possession, write a function that returns the minimum amount of change (the minimum sum of money) that you cannot create.

The given coins can have any positive integer value and aren't necessarily unique (i.e., you can havemultiple coins of the same value).

For example, if you're given coins = [1, 2, 5], the minimum amount of change that you can't create is 4. If you're given no coins, the minimum amount of change that you can't create is 1.

sample input: coins = [5, 7, 1, 1, 2, 3, 22] sample output: 20

· 4 min read

description

roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

Symbol       Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000

for example, 2 is written as II in roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. the number 27 is written as XXVII, which is XX + V + II.

roman numerals are usually written largest to smallest from left to right. however, the numeral for four is not IIII. instead, the number four is written as IV. because the one is before the five we subtract it making four. the same principle applies to the number nine, which is written as IX. there are six instances where subtraction is used:

  • I can be placed before V (5) and X (10) to make 4 and 9.
  • X can be placed before L (50) and C (100) to make 40 and 90.
  • C can be placed before D (500) and M (1000) to make 400 and 900.

given a roman numeral, convert it to an integer.

· 4 min read

description

Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not.

constraints

  • x >= 0
  • usage of strings is prohibited

· 3 min read

another week, another code challenge

description

given an array of integers, print a sum triangle from it such that the first level has all array elements. from then, at each level number of elements is one less than the previous level and elements at the level is be the sum of consecutive two elements in the previous level.

· 6 min read

time to solve another coding challenge.

description

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.