trish
BAN USER
- 0of 0 votes
Answer/*
- trish in United States
## Setup
The flow of a dispute is as follows:
- A charge is created by an end customer.
- Stripe receives a dispute record from the bank.
- The business responds with evidence.
- If no second dispute is received within 30 days after evidence submission, the dispute is won. If a second dispute is received, the dispute is lost.
Charge
(Maybe) Dispute Record
(Maybe) Evidence submission
(Maybe) Second Dispute Record
The raw tables generated from the API look like:
```
Charges
+---------------+-----------+
| charge_id | varchar |
| created | timestamp |
| amount | int |
| seller_id | varchar |
| customer_id | varchar |
+---------------|-----------+
Dispute Records
+----------------+-----------+
| dispute_id | varchar |
| created | timestamp |
| charge_id | varchar |
+----------------|-----------+
Evidence Submission
+-------------------+-----------+
| evidence_id | varchar |
| created | timestamp |
| charge_id | varchar |
+-------------------|-----------+
```
*/
/*
1. Can you design a unified dispute table that would allow us to compute things like the win rate, dispute rate, evidence submission rate etc?
*/| Report Duplicate | Flag | PURGE
Strip Data Engineer SQL - -2of 2 votes
AnswersAre the following statements correct in Java.
- trish in United States
String firstName = "Joe";
String lastName = new String("Mo");| Report Duplicate | Flag | PURGE
Symantec Principal Software Engineer Java - 0of 0 votes
Answerswhy can't java have multiple inheritances like c++?
- trish in United States| Report Duplicate | Flag | PURGE
- 0of 0 votes
AnswersFind the longest sequence in the array.
- trish in United States
array = {1, 4, 3, 2, 5, 7, 8, 22}
Answer = 1, 2, 3, 4, 5| Report Duplicate | Flag | PURGE
- -1of 1 vote
AnswersYou have two threads "A" and "B" and an integer "Count". "A" can increment the count up to 10(stops after that). "B" can decrements the count up to 1(stops after that). Print out the count after increment and decrements.
- trish in United States| Report Duplicate | Flag | PURGE
Data Structures - 0of 0 votes
AnswersCount the duplicates in the array ?
- trish in United States
array = {"IBM", "Amazon", "Google", "IBM"}
Another question from "Cracking the Code".| Report Duplicate | Flag | PURGE
Data Structures - 0of 0 votes
AnswersRemove duplicates in the array ?
- trish in United States
array = {"IBM", "Amazon", "Google", "IBM"}
Another question from "Cracking the Code".| Report Duplicate | Flag | PURGE
Data Structures - -2of 2 votes
AnswersReverse the values in the array.
- trish in United States
Here is the array = {1, 2, 4, 5, 7}| Report Duplicate | Flag | PURGE
Data Structures
public class StringReverseExample {
public static void main(String args[]) throws FileNotFoundException, IOException {
//original string
String str = "Sony is going to introduce Internet TV soon";
System.out.println("Original String: " + str);
//recursive method to reverse String in Java
String reverseStr = reverseRecursively(str);
System.out.println("Reverse String in Java using Recursion: " + reverseStr);
}
public static String reverseRecursively(String str) {
//base case to handle one char string and empty string
if (str.length() <= 1) {
return str;
}
return reverseRecursively(str.substring(1)) + str.charAt(0);
}
}
public class LongSequenceTest {
public static ArrayList<Integer> LongSequence(Integer... sequence) {
if (sequence == null || sequence.length == 0)
return null;
List<Integer> seqList = new ArrayList<Integer>(Arrays.asList(sequence));
Collections.sort(seqList);
List<Integer> currentSeq = new ArrayList<Integer>();
List<Integer> retSeq = new ArrayList<Integer>();
currentSeq.add(seqList.get(0));
int lastValue = seqList.get(0);
int longSeq = 0;
for(int i=1; i < seqList.size(); i++){
if(lastValue+1 == seqList.get(i)){
currentSeq.add(seqList.get(i));
lastValue++;
} else {
if(longSeq == 0 || currentSeq.size() > longSeq){
longSeq = currentSeq.size();
retSeq = currentSeq;
}
lastValue = seqList.get(i);
currentSeq = new ArrayList<Integer>();
currentSeq.add(seqList.get(i));
}
}
if (longSeq == 0 || currentSeq.size() > longSeq){
retSeq = currentSeq;
}
return (ArrayList<Integer>) retSeq;
}
public static void main(String arg[]) {
ArrayList<Integer> ret = LongSequence(7, 2, 3, 5, 6, 9);
for(Integer i : ret) {
System.out.print(i + " ");
}
}
}
public class Pets implements Comparable<Object>{
String name;
public Pets(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public int compareTo(Object o) {
if(o instanceof Pets){
return name.compareTo(o.toString());
}
throw new RuntimeException("Only works for Pets Class.");
}
@Override
public String toString() {
return name;
}
}
public class Cat extends Pets {
public Cat(String name) {
super(name);
}
}
public class Dog extends Pets {
public Dog(String name) {
super(name);
}
}
public class Test {
public static void main(String arg[]) {
Object[] pets = { new Dog("Max"), new Cat("Snow Ball"),
new Dog("Brownie"), new Cat("Not so Brownie") };
System.out.println("\nBefore Sorting:\n");
displayHouse(pets);
Arrays.sort(pets);
System.out.println("\nAfter Sorting:\n");
displayHouse(pets);
}
private static void displayHouse(Object[] pets) {
for (Object pet : pets) {
System.out.println(pet);
}
}
}
Before Sorting:
Max
Snow Ball
Brownie
Not so Brownie
After Sorting:
Brownie
Max
Not so Brownie
Snow Ball
From the book: Effictive Java(Page 20)
Avoid creating unnecessary objects -
It is often appropriate to reuse a single object instead of creating a new function-ally equivalent object each time it is needed. Reuse can be both faster and more stylish. An object can always be reused if it is immutable.
As an extreme example of what not to do, consider this statement:
String s = new String("stringette"); // DON'T DO THIS!
The statement creates a new String instance each time it is executed and none of those object creations is necessary. The argument to the String constructor("stringette") is itself a String instance, functionally identical to all of the objects created by the constructor. If this usage occurs in a loop or in a frequently invoked, millions of String instances can be created needlessly.
The improved version is simply the following:
String s = "stringette";
This version uses a single String instance, rather than creating a new one each time it is executed. Furthermore, it is guaranteed that the object will be reused by any other code running in the same virtual machine that happens to contain the same string literal.
- trish August 17, 2013
Performance will be much faster this way.
- trish August 18, 2013