Moderate Problem. Problem  Write a function to swap a number in place without temporary variables.

Slides:



Advertisements
Similar presentations
Numbers 1-20.
Advertisements

Virginia Standards of Learning 5.1 a. The student will read, write, & identify the place values of decimals through thousandths.
Sixteen Squared. 256 One Squared 1 Three Cubed.
Multiplication Facts 9 through x 5= 50 Number One.
We count one, two, three….
HundredsTensOnes 111 HundredsTensOnes 152 HundredsTensOnes =143.
Numbers in English By: Miss Hortencia Tijerina
MATH DRILLS. 376 three hundred seventy-six 508 five hundred eight.
The Cardinal Numbers Study target
The 100 chart is a tool that shows numbers from 1 to 100 in order. It can help you count, add, and subtract. Patterns- There are 10 rows on the 100.
Place Value II. Copyright © 2000 by Monica YuskaitisObjectives Know Know how to write a number in word form how to write a number in standard form how.
Numbers. 30 thirty20 twenty10 ten 1000 one thousand 29 twenty-nine19 nineteen9 nine 28 twenty-eight18 eighteen8 eight 100 one hundred 27 twenty-seven17.
COSAPI ENGLISH TRAINING PROGRAM Conducted by: Marco Loyola Florián Basic Group Class 6
Numbers ZERO 0 ONE 1 TWO 2 THREE 3 FOUR 4 FIVE 5.
UNDERSTANDING NUMERALS TO HUNDRED MILLION. The third period in our number system is MILLIONS ONES __ __ __, THOUSANDS ___ ___ ___, MILLIONS ___ ___ __,,
Jeopardy Place Value Words- Number Value Number – Words What digit Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500.
7B Unit 1 Grammar B Cardinal numbers(基数词)
Telling Time.
Unit 1Dream homes ---Grammar.
Primary Longman Elect 3A Chapter 3 Numbers
Place Value II By Monica Yuskaitis.
1 - one 2 - two 3 - three 4 - four 5 - five 6 - six 7 - seven
Numbers
STANDARD 5 TH A SUBJECT -- MATHEMATICS
Numbers >100
Numbers Let's recap !.
Place Value II.
Numbers.
What time is it? or What’s the time?.
We count one, two, three….
7B Unit 1 Grammar B Cardinal numbers(基数词)
9 X Table Go for it!.
English Communication
Play.
one thousand eight hundred twelve
Numbers 1 2 one two 3 4 three four.
Ronald Hui Tak Sun Secondary School
PLACE VALUE.
PLACE VALUE.
Look at the clock. Thirteen One Fourteen Two Fifteen Three Sixteen
May 25, Week Thirty-Two May 18, Week Thirty-One.
Counting Chart: Numbers 1 to 100
1 ONE 2 TWO.
March 10, Week Twenty-Two March 3, Week Twenty-One
Numbers Help under 1,000.
PLACE VALUE Hundred thousands Ten thousands Thousands Hundreds
  or 0. 1 one tenth.
Big numbers Play.
NUMBERS.
twenty-eight hundredths? Who has one hundred five and four tenths?
Number word cards months
Big numbers Play.
Thirty-six eighty thirty fifteen ten seventeen Forty-seven Forty-one
TIMETABLES.
Primary 5 Mathematics Whole Numbers
Numbers
Numbers and Number Names 0-20
Look at the clock. Thirteen One Fourteen Two Fifteen Three Sixteen
Decimals Year 4 (age 8-9) - Hundredths
HOW OLD ARE THEY? LET’S PLAY.
STRIKE THE NUMBER! PLAY.
MATHS TIME! nine ten eleven fifteen eight
+/- Numbers Year 6 – Place value, rounding and mental methods
+/- Numbers Year 2 – Addition and subtraction of units within 100
3,050,020 = 3,000, Write the number in words. 6,140,050 = 6,000, ,
HOW OLD ARE THEY? LET’S PLAY.
15-April 2019 LO: I can read, write, compare and order numbers with up to seven digits.
Odd and Even Numbers.
+/- Numbers Year 1 – Addition and subtraction within 20
Presentation transcript:

Moderate Problem

Problem  Write a function to swap a number in place without temporary variables.

Hints  This is a classic interview problem.  If you haven’t heard this problem before, you can approach it by taking the difference between a and b:

Problem  Given an integer between 0 and 999,999, print an English phrase that describes the integer  eg, “One Thousand, Two Hundred and Thirty Four”

Hints  This is not an especially challenging problem, but it is a long and tedious one.  Your interviewer is unlikely to ask to see every detail, but he / she will be interested in how you approach the problem.

Solution  public static String numtostring(int num) {  String[] wordarr1 = {“”,”One ”, “Two ”, “Three ”, “Four ”, “Five ”, “Six ”, “Seven ”, “Eight ”,”Nine ”};  String[] wordarr11 = {“”, “Eleven ”, “Twelve ”, “Thirteen ”, “Fourteen ”, “Fifteen ”, “Sixteen ”, “Seventeen ”, “Eighteen ”, “Nineteen ”};  String[] wordarr10 = {“”,”Ten ”, “Twenty ”, “Thirty ”, “Forty ”, “Fifty ”, “Sixty ”, “Seventy ”, “Eighty ”, “Ninety “};  String[] wordarr100 = {“”, “Hundred ”, “Thousand ”};  // Count number of digits in num.  Init results  If num is zero {do something }  If num is between 0- 9  if num is between  If num is between  If num is > than 999  }

Problem  You are given an array of integers (both positive and negative).Find the continuous sequence with the largest sum.Return the sum.  EXAMPLE  Input: {2, -8, 3, -2, 4, -10}  Output: 5 (i.e., {3, -2, 4} )

hints  A simple linear algorithm will work by keeping track of the current subsequence sum. If that sum ever drops below zero, that subsequence will not contribute to the subsequent maximal subsequence since it would reduce it by adding the negative sum.  MinMax is one of the positive number  In previous example, minMax=4

Problem  Design an algorithm to find all pairs of integers within an array which sum to a specified value.  One easy and (time) efficient solution involves a hash map from integers to integers. This algorithm works by iterating through the array. On each element x, look up sum - x in the hash table and, if it exists, print (x, sum - x).Add x to the hash table, and go to the next element.